Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2935.137/UITableView.m:6509
2016-01-18 12:35:16.816 ALJ Jobs[1008:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
*** First throw call stack:
这是我在Objective-c编程中遇到问题的代码。
@implementation myCV
{
NSMutableArray *CvArr;
NSMutableArray *address;
}
-(void) viewDidLoad
{
[super viewDidLoad];
CvArr = [[NSMutableArray alloc] initWithObjects:@"My Cv_0",@"My Cv_1",@"My Cv_2",@"My Cv_3",@"My Cv_4", nil];
address = [[NSMutableArray alloc] initWithObjects:@"Pakistan_0",@"Pakistan_1",@"pakistan_2",@"pakistan_3",@"pakistan_4",nil];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [CvArr count];
}
-(UITableViewCell *)tabelView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *reUseid=@"cellID";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:reUseid];
if (cell==nil)
{
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reUseid];
}
Cell.textLabel.text = [CvArr objectAtIndex:indexPath.row];
return Cell;
}
答案 0 :(得分:0)
尝试以下代码,希望它能解决您的问题。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableItem";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [CvArr objectAtIndex:indexPath.row];
return cell;
}