gpt4 book ai didi

objective-c - 复选标记代码错误

转载 作者:行者123 更新时间:2023-11-28 20:33:09 25 4
gpt4 key购买 nike

在我的 cellForRow 代码中,我有以下内容,但收到一条错误消息,提示未返回任何内容。我做错了什么?谢谢。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
if([self.checkedIndexPath isEqual:indexPath])
{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else
{
cell.accessoryType = UITableViewCellAccessoryNone;
}
return cell;
}

最佳答案

这是一个无限循环:UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];

这应该是:

static NSString *reuseIdentifier = @"some_identifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
if(cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier] autorelease]
}

关于objective-c - 复选标记代码错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11529358/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com