【发布时间】:2012-01-31 22:57:01
【问题描述】:
这让我发疯了!
我有一个带有通用原型单元格的通用 UITableViewController 类,标识符为“myCell”。在ARC、iOS5下开发,使用Storyboard,我使用的方法如下:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"myCell"];
cell.textLabel.text = @"Title";
return cell;
}
一切都与故事板、文件所有者等相关联。我的项目中还有其他几个 UITableViewController,使用相同的概念。所有人都在工作。 这个特殊的 UITableViewController 类不想工作!继续向我抛出异常:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
Nslog'ed --> [tableView dequeueReusableCellWithIdentifier:@"myCell"] = (null)
非常感谢任何想法和帮助!
编辑:
为简单起见: - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 返回 1; }
我已经做过的事情: 1.在storyboard中删除并创建和设置UITableViewController! 2.重启Xcode 3.重启模拟器 4. 重启电脑!!!! 5.一遍又一遍地删除和构建应用程序! 没有任何效果。
顺便说一下,我试过了
if (cell == nil)
cell = [UITableViewCell alloc] initWithStyle....
.. 它会解决问题,但同样...这是 ARC,故事板,...我不应该那样做。 Xcode 应该会处理它!
【问题讨论】:
-
我也有同样的问题。你能告诉你是如何解决这个问题的吗?我必须错过故事板配置中的某些内容。
-
还没弄明白。如果我找到答案,我会在这里发布。
-
看起来我们在故事板中遗漏了一些东西。它可能有一些我们需要更改的默认行为。我想知道有多少人有同样的问题......
标签: xcode4 uitableview storyboard automatic-ref-counting