gpt4 book ai didi

ios - 没有 cellidentifier ios 的 cellForRowIndexPath

转载 作者:行者123 更新时间:2023-11-28 18:36:05 26 4
gpt4 key购买 nike

我的项目中没有 xib 文件或 Storyboard。在这种情况下,我该如何设置小区标识符?下面是我的代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"test");
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell.textLabel.text = [self.entries objectAtIndex:indexPath.row];
return cell;
}

最佳答案

尝试用这个替换你的代码(使用 ARC):

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

cell.textLabel.text = [self.entries objectAtIndex:indexPath.row];

return cell;
}

++

关于ios - 没有 cellidentifier ios 的 cellForRowIndexPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18872392/

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