2015-08-15 29 views
-1

我正在使用自定義Cell類來繪製單元格上的UITableView。當我第一次加載數據,細胞==零被稱爲UITableView - 當ReloadData沒有調用Cell時

if (cell == nil) 
{ 
    cell = [[[NSBundle mainBundle] loadNibNamed:@"ZACustomCellTableViewCell" owner:self options:nil] objectAtIndex:1]; 
} 

但是我重裝數據第二次控制永不熄滅內細胞==零

我試圖設置數據源即字典爲零,並重新加載沒有成功。我需要做些什麼來重新從頭開始重新加載單元格?

+1

這是哪裏的代碼片段?什麼方法?你是否使用了longwinded但是故意命名的'dequeue ** ReusableCell ** WithIdentifier?' – stevesliva

+0

爲什麼在調用'reloadData'後你希望'cell'是'nil'?細胞得到重用。一旦表格中有一個充滿單元格的屏幕,'cell'通常不會再被'無'。 – rmaddy

+0

你只有單元重新加載或表? –

回答

0

請按照下面的步驟

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

{ 

    static NSString *cellIdentifier = @"ZACustomCellTableViewCell"; 

    cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 

    if (cell == nil) 

    { 

     cell = [[[NSBundle mainBundle] loadNibNamed:@"ZACustomCellTableViewCell" owner:self options:nil] lastObject]; 

    } 

    cell.labelForServiceProviderName.text = [arrayForServiceProvider objectAtIndex:indexPath.row]; 

    return cell; 
} 
相關問題