2014-02-07 18 views
0

我在tableview中有三个部分。三节单元包含3个不同的视图控制器。当用户有机会在桌面视图中点击2个不同部分时,由于后退导航崩溃,我们会崩溃。 UINavigationController异常。我们如何禁用该部分以避免多次分离。iOS - Objective C - UITablview部分禁用

回答

0

你应该忽略电池部分,你不想来处理:

0
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    //once you get control in this section disable the table for 1 second than in this duration your navigation controller will pop and user will not able to tap second time 

    [self performSelector:@selector(enableTable) withObject:nil afterDelay:1.0]; 
    tbl.userInteractionEnabled=NO; 

} 

-(void)enableTable 
{ 
    tbl.userInteractionEnabled=YES; 
} 
0

有一个表视图委托方法的tableView:willSelectRowAtIndexPath:

OS将调用之前的方法选择一个单元格。

实现该方法,并且如果索引路径中的部分是不想选择的部分,则返回nil。

如果你的节数定义为K_SECTION_TO_IGNORE,你的代码可能是这样的:

#define K_SECTION_TO_IGNORE 1 

- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (indexPath.section == K_SECTION_TO_IGNORE) 
    return nil; 
    else 
    return indexPath; 
}