亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

dequeueReusableCellWithIdentifier:forIndexPath:

dequeueReusableCellWithIdentifier:forIndexPath:

慕哥6287543 2019-07-04 13:04:44
dequeueReusableCellWithIdentifier:forIndexPath:中的斷言失敗所以我為我的學校制作了一個RSS閱讀器并完成了代碼。我做了測試它給了我那個錯誤。下面是它所指的代碼:- (UITableViewCell *)tableView:(UITableView *)tableView           cellForRowAtIndexPath:(NSIndexPath *)indexPath {     static NSString *CellIdentifier = @"Cell";     UITableViewCell *cell =       [tableView dequeueReusableCellWithIdentifier:CellIdentifier                                       forIndexPath:indexPath];     if (cell == nil) {         cell =           [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle                                   reuseIdentifier:CellIdentifier];     }以下是輸出中的錯誤:2012年-10-04 20:13:05.356閱讀器[4390:C07]*斷言失敗出現在-[UITableView dequeueReusableCellWithIdentifier:forIndexPath:],/SourceCache/UIKit_Sim/UIKit-2372/UITableView.m:4460 2012-10-04 20:13:05.357 Reader[4390:C07]*由于“NSInternalInconsistencyException”異常終止應用程序,原因是:“無法用標識符單元格排出單元格-必須為標識符注冊一個nib或類,或者在情節提要中連接一個原型單元格”*First throw call stack:(0x1c91012 0x10cee7e 0x1c90e78 0xb64f35 0xc7d14 0x39ff 0xd0f4b 0xd101f 0xb980b 0xca19b 0x6692d 0x10e26b0 0x228dfc0 0x228233c 0x228deaf 0x1058cd 0x4e1a6 0x4ccbf 0x4cbd9 0x4be34 0x4bc6e 0x4ca29 0x4f922 0xf9fec 0x46bc4 0x47311 0x2cf3 0x137b7 0x13da7 0x14fab 0x26315 0x2724b 0x18cf8 0x1becdf9 0x1becad0 0x1c06bf5 0x1c06962 0x1c37bb6 0x1c36f44 0x1c36e1b 0x147da 0x1665c 0x2a02 0x2935)libc++abi.dylib:terminate called throwing an exception下面是它在錯誤屏幕中顯示的代碼:int main(int argc, char *argv[]){     @autoreleasepool {         return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));     }}救命?。?
查看完整描述

3 回答

?
蝴蝶刀刀

TA貢獻1801條經驗 獲得超8個贊

你用的是dequeueReusableCellWithIdentifier:forIndexPath:方法。這個文獻資料對于該方法來說,如下所示:

重要:必須使用registerNib:forCellReuseIdentifier:registerClass:forCellReuseIdentifier:方法之前調用此方法。

您沒有為重用標識符注冊nib或類"Cell".

查看您的代碼,您似乎期望deQueue方法返回。nil如果它沒有手機給你。您需要使用dequeueReusableCellWithIdentifier:對于這種行為:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

注意dequeueReusableCellWithIdentifier:dequeueReusableCellWithIdentifier:forIndexPath:是不同的方法。見醫生前者后者.

如果你想知道為什么你想用dequeueReusableCellWithIdentifier:forIndexPath:看看這個問答.


查看完整回答
反對 回復 2019-07-04
?
忽然笑

TA貢獻1806條經驗 獲得超5個贊

我也有同樣的問題

static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

   if (cell==nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];

    }


查看完整回答
反對 回復 2019-07-04
  • 3 回答
  • 0 關注
  • 989 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號