我有一個帶有30個對象的UITableView。 控制器正確顯示第13行,第14行使用「joker」行更改其內容滾動,然後再以第13行和「joker」行重新開始,直到結束。TableView重複第13行
這是cellForRowAtIndexPath
方法的代碼:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: @"cell" forIndexPath:indexPath];
UIImageView * flagImageView = (UIImageView *) [self.view viewWithTag:1];
UILabel * nationLabel = (UILabel *) [self.view viewWithTag:2];
nationLabel.text = [_nationsArray objectAtIndex:indexPath.row];
nationLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
NSLog(@"%i", indexPath.row);
return cell;
}
奇怪的是,在if (cell == nil) { ... }
配置細胞不起作用......
什麼是「joker」行?你能不能顯示你的控制器的其他部分? – Stas
是顯示正在加載的行的行。它很難解釋和很奇怪的事情;如果你使用的是xCode 5 DP,那麼我發佈代碼 –
我想知道你爲什麼得到13行。你沒有對你的細胞做任何事情!! – CRDave