Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS-目标C-UITABLEVIEW部分禁用_Ios_Objective C_Uitableview - Fatal编程技术网

iOS-目标C-UITABLEVIEW部分禁用

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

我在tableview中有三个部分。三部分单元包含3个不同的视图控制器。当用户有机会点击tableview中的两个不同部分时,我们会因为反向导航崩溃而崩溃。UINavigationController异常。如何禁用分区以避免多次选择。

您应该忽略不希望处理的单元格分区:

-(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;
}