开发者

IOS: delegate methods for two tableView

myaI have this code:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {


if (tableView == firstTableView){

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil){
    cell = [[[UITableViewCell alloc]initWithStyle:UITableViewStylePlain reuseIden开发者_运维问答tifier:CellIdentifier] autorelease] ; 
}

cell.textLabel.text = [myArray objectAtIndex:indexPath.row];

return cell;
}
}

I check if tableview is firsttableview, but it give me a warning because the method haven't a "return" cell, how can I solve?


You only return a cell if the table is firstTableView. Make sure you return a cell for other tables by adding a return statement outside of your conditional.


Your code needs to return a value for all paths through that method. So, if your check for firstTableView fails, you still need to return a valid UITableViewCell from the method. You should probably read the UITableView programming guide - it walks you through proper usage of a tableview.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜