【发布时间】:2014-01-20 15:14:27
【问题描述】:
我有 2 个表视图,第一个仅从数组加载列表。 另一个 1,显示每行的详细信息。但它显示了一个崩溃报告:
'UITableView dataSource 必须从 tableView 返回一个单元格:cellForRowAtIndexPath: Exception'
我的代码似乎有什么问题?我想向每一行显示来自同一 sqlite 行的不同细节。
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell;
//tableView 1
if(tableView == self.cTableLabel)
{
cell = [tableView dequeueReusableCellWithIdentifier:@"courseCell"];
NSLog(@"Here.");
Course *courses = [self.course objectAtIndex:indexPath.row];
cell.textLabel.text =courses.cName;
cell.detailTextLabel.text =courses.cSchool;
return cell;
}
//tableView 2
if(tableView == self.jTableLabel)
{
if (indexPath.row == 0)
{
cell = [tableView dequeueReusableCellWithIdentifier:@"JobName"];
cell.textLabel.text = _jDetails.jName;
}
else if (indexPath.row == 1)
{
cell= [tableView dequeueReusableCellWithIdentifier:@"JobEarnings"];
cell.textLabel.text = @"Job Earnings (per month): Php";
cell.detailTextLabel.text = _jDetails.jEarnings;
}
return cell;
}
return 0;
}
【问题讨论】:
标签: ios objective-c uitableview