0
我正在創建自定義UITableViewCell
。在ios7中這工作得很好,但在iOS8中,我所有的子類屬性突然記錄爲零。自定義UITableViewCell突然記錄所有屬性值爲零
這是我的代碼:
if(indexPath.section == 0){
NSString *headerIdentifier = @"HeaderCell";
HeaderTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:headerIdentifier];
if (!cell) {
cell = [[HeaderTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:headerIdentifier];
}
NSLog(@"headercell: %@",cell); // this logs a neat uitableviewcell
cell.profileImage.image = [UIImage imageNamed:@"profilePlaceholder.jpg"];
CALayer * l = [cell.profileImage layer];
[l setMasksToBounds:YES];
[l setCornerRadius:33.0];
cell.settingsView.image = [UIImage imageNamed:@"settings.png"];
NSLog(@"%@",cell.settingsView.image); //logs nil :(
CALayer *settings = [cell.settingsView layer];
[settings setCornerRadius:12.0];
[settings setMasksToBounds:YES];
}
當我打電話cell.textLabel = @"TEST"
,該單元格顯示TEST不過..
我已經把我的班,我的故事板權和進口自定義的頭文件細胞也是如此。我不知道爲什麼它不能寫入這些屬性。
編輯
至於那種Acey的意見建議,這可能是因爲我的故事板無法識別的標識,但實際上我有設置是正確的。在此處查看屏幕截圖:
感謝您的回答1 :)我嘗試了您建議的方法,並得到一個運行時錯誤:''無法使標識符HeaderCell出列單元格 - 必須爲標識符註冊一個nib或類或連接故事板中的原型單元格「這是iOS8以來的新功能嗎?我無法將自定義的'UITableViewCell'連接到ViewController,因爲這是一個'非法配置' – bdv 2014-09-24 17:54:59
當試圖修復它,這個答案(http://stackoverflow.com/questions/19084274/xcode-unable-to-dequeue- a-cell-with-identifier)指向相反的方向。 – bdv 2014-09-24 18:06:33
啊哈。正如我懷疑的那樣,你從未註冊過你的手機。不,這不是新的。在製作單元格的故事板中,確保標識符與代碼中的相同。另外,如果要在故事板中創建單元格,請確保您在包含單元格的表格視圖中調用出列。在故事板中創建原型單元格會自動爲您註冊,但標識符必須匹配。 – Acey 2014-09-24 18:09:08