-2
我下面this教程創建一個自定義的UITableViewCell,並在對象從返回從[tableView dequeueReusableCellWithIdentifier:@"ID"]
,所有的UILabels和等都是nil
。本教程不說有關創建他們自己什麼,我希望我不會需要,內部監督辦公室的其餘部分的工作方式來看,但我不知道爲什麼沒有被自動創建他們。例如,這裏cell.lightName
是nil
,即使它掛接到離開,在IB的自定義視圖的標籤。我必須創建所有的UI元素自己使用自定義的UITableViewCell什麼時候?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *dataCellIdentifier = @"Data Cell";
AnalysisHistoryTableViewCell *cell = (AnalysisHistoryTableViewCell*)[tableView dequeueReusableCellWithIdentifier:dataCellIdentifier forIndexPath:indexPath];
self.selectedAnalysis = self.analysisResults[indexPath.row];
cell.lightNameLabel.text = self.selectedAnalysis.lightName;
return cell;
}
我在做什麼錯誤導致我的UILabel
s不存在?
我假設你AnalysisHistoryTableViewCell已合成的屬性,連接到您的手機中的UILabel。 – userx
你有登記表視圖('registerNib:')筆尖? – sooper
你使用Xib還是故事板?你在哪裏宣佈標籤?你是否合成了標籤? – vnchopra