ios 5.1.1上的Xcode 4.5.1 ios二进制文件导致错误

时间:2012-10-06 09:07:02

标签: ios xcode

我刚买了一台新Mac,我从Appstore下载了Xcode(4.5.1)。默认情况下,当您创建一个新项目时(在我的情况下使用启用了Storyboard的主/明细模板),它会以ios 6.0为目标,并且该项目在我已升级到6.0的iPhone上运行正常。

要在我的iPhone 5.1.1上运行它,我更改了部署目标。在UITableView中添加并显示项目时运行5.1.1我收到以下错误:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason:' -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:]: 
unrecognized selector sent to instance 0x1023b800'

这是拖欠错误的代码

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

    NSDate *object = _objects[indexPath.row];
    cell.textLabel.text = [object description];
    return cell;
}

从我以前的iPhone项目开始,我常常在

下面看到这个
if(cell == nil)
// Create the cell

但我认为我不需要这个,因为故事板已经有一个Cell添加到UITableView。

任何提示..?

最好的regaards 奥伊斯坦

2 个答案:

答案 0 :(得分:6)

问题可以在[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] documentation;

中找到
  

适用于iOS 6.0及更高版本。

答案 1 :(得分:1)

我将违规代码行更改为

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" ];

基本上放弃forIndexPath:indexPath并且它有效。现在我正在尝试更多代码,如果这会导致问题,我会报告。