【发布时间】:2013-02-25 00:18:53
【问题描述】:
查看其他类似问题后,我不确定错误出在哪里。 我收到了一个断言失败。
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:
我认为这很简单,但希望有人能提供帮助。
下面是我的代码:
#import "StockMarketViewController.h"
@interface StockMarketViewController ()
@end
@implementation StockMarketViewController
@synthesize ShareNameText, ShareValueText, AmountText;
@synthesize shares, shareValues;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
{
return [shares count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
NSString *currentValue = [shareValues objectAtIndex:[indexPath row]];
[[cell textLabel]setText:currentValue];
return cell;
}
【问题讨论】:
-
请更新您的问题以标记导致异常的行。如果您不知道,请设置断点并单步执行代码,直到找到确切的行。
-
嗯,我是 xcode 的新手,所以我不确定这些东西,但在这种情况下,没有出现错误,并且当我选择相关页面时程序运行但崩溃?所以我不知道哪一行是错误的,如果这是有道理的?我想 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
-
实际上是否有一个带有(区分大小写)标识符@"cell"的单元格?
-
如果不是这样会导致问题吗?正如我所说,我对此很陌生,并且正在使用教程来帮助我,这是他们使用的代码的一部分。
-
如果有帮助,请更新问题,谢谢。
标签: ios objective-c cocoa-touch uitableview