iOS-目标C-UITABLEVIEW部分禁用
我在tableview中有三个部分。三部分单元包含3个不同的视图控制器。当用户有机会点击tableview中的两个不同部分时,我们会因为反向导航崩溃而崩溃。UINavigationController异常。如何禁用分区以避免多次选择。您应该忽略不希望处理的单元格分区:iOS-目标C-UITABLEVIEW部分禁用,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我在tableview中有三个部分。三部分单元包含3个不同的视图控制器。当用户有机会点击tableview中的两个不同部分时,我们会因为反向导航崩溃而崩溃。UINavigationController异常。如何禁用分区以避免多次选择。您应该忽略不希望处理的单元格分区: -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if ([indexPath.sec
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([indexPath.section == 1) // Don't do anything where row in section 1 is pressed
return nil;
else
{
//handle cell selection
}
}
有一个表视图委托方法tableView:WillSelectRowatineXpath: 操作系统将在选择单元格之前调用该方法 实现该方法,如果索引路径中的部分是您不想选择的部分,则返回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;
}
#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;
}