(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView == method) {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *methodcell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(methodcell == nil){
methodcell = [[UITableViewCell alloc]initWithStyle:UITableViewStylePlain reuseIdentifier:CellIdentifier];
}
methodcell.textLabel.text = [methodarray objectAtIndex:indexPath.row];
return methodcell;
}
else if (tableView == schedule){
static NSString *CellIdentifier = @"Cell";
UITableViewCell *schedulecell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(schedulecell == nil){
schedulecell = [[UITableViewCell alloc]initWithStyle:UITableViewStylePlain reuseIdentifier:CellIdentifier];
}
schedulecell.textLabel.text = [ScheduleArray objectAtIndex:indexPath.row];
return schedulecell;
}
}
答案 0 :(得分:2)
问题是你的函数有的可能性没有返回任何东西。例如,如果您的if
和else if
语句都返回FALSE
,则您的函数将不会返回任何内容。此功能要求您返回一些内容,因此您有几个选项(完全取决于您想要完成的任务):
return nil;
(如果没有执行if
分支,则不返回单元格)else if
更改为else
,以便在if
返回FALSE
else
声明if
分支
醇>
总之,您需要在该函数调用结束时返回 某些内容 。
答案 1 :(得分:1)
如果{},可以在{}之外将单元格转义为外部,如果是{},则根据tableView配置它并返回。
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil){
cell = [[UITableViewCell alloc]initWithStyle:UITableViewStylePlain
reuseIdentifier:CellIdentifier];
}
if (tableView == method) {
//configure cell for method tableView
} else if (tableView == schedule) {
//configure cell for schedule tableView
}
return cell;