iOS5中my UITableView中的dequeueReusableCellWithIdentifier错误
我在iOS 5中遇到了这个错误iOS5中my UITableView中的dequeueReusableCellWithIdentifier错误,ios,ios5,uitableview,ios6,Ios,Ios5,Uitableview,Ios6,我在iOS 5中遇到了这个错误 -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:]:发送到实例0xa217200的选择器无法识别 但是,我在iOS 6中没有发现错误。我如何解决这个问题?这是我的密码: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { sta
-[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中使用的额外参数。(forindexath:)
所以改变你的方法。它会起作用的。以下是出现错误的原因。根据iOS 6.0文档集,UITableView类参考说明,iOS 2.0及更高版本中提供了
dequeueReusableCellWithIdentifier:
,iOS 6.0及更高版本中提供了dequeueReusableCellWithIdentifier:forIndexPath:
需要将tableView委托方法粘贴到此处。请提供足够的代码以获取答案感谢Apple为UITableViewController创建默认模板代码,使用仅限iOS6的方法而不告诉我们!