UITableView cellForRowAtIndexPath,抵消数组

时间:2012-01-10 23:07:38

标签: xcode uitableview

我有这两行代码将文本加载到UITableViewCell。

NSDictionary *aTweet = [tweets objectAtIndex:[indexPath row]];
cell.textLabel.text = [aTweet objectForKey:@"from_user"];

我试图偏移[indexPath行],所以它只开始填充第二个Cell,因为我有一个自定义UITableViewCell填充第一个Cell。

1 个答案:

答案 0 :(得分:0)

为什么不直接测试行号并使用相应的代码,如下所示:

if ([indexPath row] == 0) {
    // take care of the first row
}
else {
    NSDictionary *aTweet = [tweets objectAtIndex:[indexPath row]-1];
    cell.textLabel.text = [aTweet objectForKey:@"from_user"];
}