gpt4 book ai didi

ios - iOS5 中我的 UITableView 出现 dequeueReusableCellWithIdentifier 错误

转载 作者:IT王子 更新时间:2023-10-29 07:36:50 24 4
gpt4 key购买 nike

我在 iOS 5 中遇到这个错误

-[UITableView dequeueReusableCellWithIdentifier:forIndexPath:]: 无法识别的选择器发送到实例 0xa217200

但是,我在 iOS 6 中没有遇到任何错误。我该如何解决这个问题?这是我的代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"MyCell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; /// SIGABRT error

if (!cell)
{
cell = [[UITableViewCell alloc]
initWithStyle: UITableViewCellStyleSubtitle
reuseIdentifier: CellIdentifier];
}

return cell;
}

最佳答案

编辑:此方法是在 iOS6+ SDK 中新添加的。

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

但在 iOS 5 中,要创建 UITableViewCell 的实例,我们通常使用这种方法:-

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

在 iOS 5 中,不需要您在 iOS 6 中使用的额外参数。(forIndexPath:)。

所以改变你的方法。它会起作用。

关于ios - iOS5 中我的 UITableView 出现 dequeueReusableCellWithIdentifier 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12016331/

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