2013-11-21 104 views
1

我有與tableview動態原型單元格,甚至我改變我的單元格樣式字幕或其他東西或添加附件我的單元格總是顯示爲基本樣式單元格的uitableviewcontroller。具有動態原型和自定義單元格的iOS UITableView

這裏是我的cellForRowAtIndexPath功能:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    NSInteger row = indexPath.row; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 

    if (_dataArray && row < self.dataArray.count) { 
     cell.textLabel.text = self.dataArray[row]; 
    } 

    return cell; 
} 

編輯:有件事我不明白,也許有人可以解釋這一點。早些時候,我的應用程序崩潰,當我告訴我的表視圖控制器,所以我不得不把它添加到viewDidLoad方法:

[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:CellIdentifier]; 

後,該應用程序並沒有崩潰,但它造成的是我無法改變的單元格樣式。現在我可以刪除它,我的應用程序不會崩潰,我可以更改單元格樣式。爲什麼?

我在做什麼錯?

回答

0

確保您在故事板中設置單元格的標識符。

enter image description here

另外使用標籤來從故事板改性劑UI元素:

UIImageView *imageView = (UIImageView *)[cell viewWithTag:1]; 
UILabel *eventNameLabel = (UILabel *)[cell viewWithTag:2]; 
+0

是,所述標識符被設置。我使用基本的單元格樣式,但是當我選擇例如披露指標作爲輔助視圖,那麼它沒有顯示。它顯示我何時刪除註冊單元格。 –

相關問題