2013-05-30 29 views
0

我创建了一个tableviewcontroller来处理tableview中的4个静态单元格。桌面视图位于4个单元的正下方。但是,最后一个单元格4th cell是基于第三个单元格的结果是可选的。为什么我的tableview在标识符上崩溃?

选取器返回一个值,当它返回时,它会重新加载tableview以激活第4个单元格,如果该值是正确的。

SettingsViewController

当运行它崩溃上与此错误装载SettingsViewController该应用:

终止应用程序由于未捕获的异常“NSInternalInconsistencyException”,原因:“无法出列具有标识符细胞的细胞 - 必须注册一个笔尖或类的标识符或连接故事板的原型单元格'

我以为我不需要重用标识符,如果我有静态单元格?

下面是相关的代码:

#pragma mark - Table view data source 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    // Return the number of sections. 
    return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    if(self.showLastCell) 
    { 
     return 4; 
    } 
    return 3; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 

    // Configure the cell... 

    return cell; 
} 

回答

0

你不需要出列吧,如你所说,这只是静态的细胞。

相反的:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 

用途:

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 

祝你好运!

编辑:太慢了!