私はストーリーボードファイルで識別子 "mainViewTableCell"を持つプロトタイプセルを作成し、メインテーブルビューを "NTTableViewController"という名前のカスタムコントローラクラスに接続しました。 次のように私はNTTableViewController.mで機能「のtableView cellForRowAtIndexPath」を実装しました:dequeueReusableCellWithIdentifierからnilを取得し続けますか?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString* MAINVIEW_CELLIDENTIFIER = @"mainViewTableCell";
UITableViewCell *newCell = [tableView dequeueReusableCellWithIdentifier: MAINVIEW_CELLIDENTIFIER];
if (newCell == nil) {
newCell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleSubtitle reuseIdentifier: MAINVIEW_CELLIDENTIFIER];
[newCell autorelease];
newCell.selectionStyle = UITableViewCellSelectionStyleNone;
}
NTContactItem* currentItem = [self.contactItemContainer objectInContainerAtIndex: indexPath.row];
NSString* firstName = currentItem.firstName;
NSString* lastName = currentItem.lastName;
NSString* fullName = [firstName stringByAppendingFormat: lastName];
[newCell.textLabel setText: fullName];
[newCell.detailTextLabel setText: currentItem.mobilePhone];
return newCell;
}
しかし、私はdequeueReusableCellWithIdentifierからnilを取得維持し、セルの新しいインスタンスを毎回作成する必要があります。
次に、何が間違っていますか?
コード:project
は、事前にすべてのいただきありがとうございます。
はあなたが、まさにこの同じ文字列に、このプロトタイプセルの識別子を設定してください。ストーリーボードに? –
@FirozeLafeer私は確信しています。実際に私は問題を発見したときにそれを最初にチェックしました。 –