2017-06-19 7 views
0

それちょうど非常に基本的なもの、私はのUITableViewCellは - TextLabel.textは常にNULLです

cell.textLabel.text   = @"Notification"; 
cell.detailTextLabel.text = @"Dates"; 
を行うとき、私はこの方法では、

今セルスタイル「右の詳細」でcellForRowAtIndexPathをのUITableViewを使用しています

テキストは画面に表示されません。私は

NSLog(@"%@ -- %@",cell.textLabel.text, cell.detailTextLabel.text); 

のようなセルのテキストをログに記録する場合は、コンソールに次の行を出力します。ここ

(null) -- (null) 

は、いくつかの詳細は以下のとおりです。

Xcodeのバージョン:8.3.1

シミュレータ: iPad Pro(12.9インチ)iOS 10.3

ストーリーボードベースのテーブルビュー スタイルオプションから既に「正しい詳細」オプションが選択されています。 が既にリクエストで次の

[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:identifier] 

をテストし、ここでは "CellForRowAtIndexpath" のための完全なコードがある

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 
    UITableViewCell *cell = nil; 
    if (tableView == self.tableviewBusinessSettings) { 
     NSString *identifier = @"BCell"; 
     cell = [tableView dequeueReusableCellWithIdentifier:identifier];\ 
     NSDictionary *dictSetting = [self.arrayBusinessSettings objectAtIndex:indexPath.row]; 
     [cell.textLabel setText:[dictSetting objectForKey:@"key"]]; 
     [cell.detailTextLabel setText:[dictSetting objectForKey:@"value"]]; 
    }else if (tableView == self.tableviewNotifications) { 

     NSString *identifier = @"NCell"; 
     cell = [tableView dequeueReusableCellWithIdentifier:identifier]; 
     cell.textLabel.text   = @"Notification"; 
     cell.detailTextLabel.text = @"Dates"; 
    } 

    NSLog(@"%@ -- %@",cell.textLabel.text, cell.detailTextLabel.text); 

    return cell; 
} 

迅速な助けが必要。

おかげ

+0

'cell'はnullですか? 'cell.textLabel'はnullですか? 'cell.detailTextLabel'はnullですか? 'cellForRowAtIndexPath:'コード全体を表示できますか?セルをデキューしましたか? – Larme

+0

あなたの問題を理解できるように**完全な** cellForRowAtIndexPath **メソッドを表示してください。ありがとう – gEeKyMiNd

+0

どちらのセルもnullでもcell.textLabelでもないので、インデックスの行の完全なセルを表示させてください – CevianTech

答えて

0

)(ただのNSLogのtableViewのセルに送信する前に、同じように、辞書内のデータをチェックデータは、あなたが送信され、他の事は

cell.textlabel.text = [dictSetting objectForKey:@"key"]; 
cell.detailTextLabel.text = [dictSetting objectForKey:@"value"]; 

を使用して試してみて、交換してみてみ

UITableViewCell *cell = nil; to UITableViewCell *cell; 
+0

答えをありがとう – CevianTech

関連する問題