UITableView cellForRowAtIndexPath,偏移阵列
问题描述:
我有这两行代码将文本加载到UITableViewCell中。UITableView cellForRowAtIndexPath,偏移阵列
NSDictionary *aTweet = [tweets objectAtIndex:[indexPath row]];
cell.textLabel.text = [aTweet objectForKey:@"from_user"];
我试图抵消[indexPath行]所以它只开始填充第二小区,因为我有一个自定义的UITableViewCell填补了第一个单元格。
答
你为什么不只是测试的行号,并使用相应的代码,像这样:
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"];
}