Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/112.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 复选标记在tableview中不起作用_Ios_Uitableview - Fatal编程技术网

Ios 复选标记在tableview中不起作用

Ios 复选标记在tableview中不起作用,ios,uitableview,Ios,Uitableview,在我的iOS应用程序中,我有一个tableView,当你点击该单元格时,会显示一个复选标记。但是,当您再次单击单元格时,复选标记不会消失。我一遍又一遍地检查我的代码。以下是与UITableViewAccessoryCheckmark有关的两种方法: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *Cel

在我的iOS应用程序中,我有一个tableView,当你点击该单元格时,会显示一个复选标记。但是,当您再次单击单元格时,复选标记不会消失。我一遍又一遍地检查我的代码。以下是与
UITableViewAccessoryCheckmark
有关的两种方法:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

PFUser *user = [self.allUsers objectAtIndex:indexPath.row];
cell.textLabel.text = user.username;

if ([self isFriend:user]) {
    cell.accessoryType = UITableViewCellAccessoryNone;
}
else {
    cell.accessoryType = UITableViewCellAccessoryNone;
}

return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.tableView deselectRowAtIndexPath:indexPath animated:NO];

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

PFRelation *friendsRelation = [self.currentUser relationforKey:@"friendsRelation"];
PFUser *user = [self.allUsers objectAtIndex:indexPath.row];

if ([self isFriend:user]) {
    cell.accessoryType = UITableViewCellAccessoryNone;

    for(PFUser *friend in self.friends) {
        if ([friend.objectId isEqualToString:user.objectId]) {
            [self.friends removeObject:friend];
            break;
        }
    }

    [friendsRelation removeObject:user];
}
else {
    cell.accessoryType = UITableViewCellAccessoryCheckmark;
    [self.friends addObject:user];
    [friendsRelation addObject:user];
}

[self.currentUser saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
    if (error) {
        NSLog(@"Error: %@ %@", error, [error userInfo]);
    }
}];
}

有人能帮我发正确的密码吗?谢谢大家!

尝试将附件视图设置为零


我的错,你能发布一些
[self isFriend:user]
的代码吗?它做的事情完全一样
cell.accessoryView = nil;