我已經看到幾個類似的帖子關於原型單元格不更新,並試圖通過一堆答案後,我必須張貼我自己的問題。像許多人一樣,我創建了UITableViewCell的一個子類,並將多個屬性鏈接到Xcode中的原型單元格。自定義UITableViewCells不更新(原型單元格)
自定單元的.H
@property (strong, nonatomic) IBOutlet UILabel *playerNameLabel;
@property (strong, nonatomic) IBOutlet UILabel *positionLabel;
@property (strong, nonatomic) IBOutlet UILabel *playersPositionLabel;
@property (strong, nonatomic) IBOutlet UILabel *teamLabel;
@property (strong, nonatomic) IBOutlet UILabel *playersTeamLabel;
@property (strong, nonatomic) IBOutlet UIImageView *logoView;
@property (strong, nonatomic) IBOutlet UIView *layerView;
而且在我的ViewController文件,我使用下面的代碼。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
PlayerTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"playerCell" forIndexPath:indexPath];
if ([self.playerSearchBar.text isEqualToString: @""]) {
Player *player = self.playerArray[indexPath.row];
cell.playerNameLabel.text = player.fullName;
cell.playersPositionLabel.text = player.position;
cell.playersTeamLabel.text = player.team;
} else {
Player *player = self.filteredPlayerArray[indexPath.row];
cell.playerNameLabel.text = player.fullName;
cell.playersPositionLabel.text = player.position;
cell.playersTeamLabel.text = player.team;
}
return cell;
}
有趣的是,數據在那裏,我可以在調試器中看到它,但沒有標籤更新。以前我用標籤做過這件事,但由於我使得單元格的設計更加複雜,我已經轉向了子類化。有什麼我可能會在這裏失蹤?
可以肯定的是:你在界面構建器中鏈接過網點嗎? –
當然!三重檢查。 – pennyloaf
你註冊了你的自定義單元嗎? –