Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.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
对于iPhone中的特定部分,如何设置编辑是肯定的_Iphone_Objective C_Uitableview - Fatal编程技术网

对于iPhone中的特定部分,如何设置编辑是肯定的

对于iPhone中的特定部分,如何设置编辑是肯定的,iphone,objective-c,uitableview,Iphone,Objective C,Uitableview,我已在.h文件中声明UITableView。我在表格视图中有5个部分,现在我需要设置表格视图。编辑=是仅适用于第4部分 如何在第4节旁边显示+按钮,并使所有其他节处于编辑状态=否 myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0,0,320,415) style:UITableViewStyleGrouped]; myTableView.delegate = self; myTableView

我已在.h文件中声明UITableView。我在表格视图中有5个部分,现在我需要设置表格视图。编辑=是仅适用于第4部分

如何在第4节旁边显示
+
按钮,并使所有其他节处于编辑状态=否

myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0,0,320,415) style:UITableViewStyleGrouped];
        myTableView.delegate = self;
        myTableView.dataSource=self;
        [myTableView setSectionFooterHeight:0];
        [myTableView setSectionHeaderHeight:15];
        [myTableView setSeparatorColor:[UIColor lightGrayColor]];
        myTableView.backgroundColor = [UIColor colorWithRed:0.85546875 green:0.8828125 blue:0.92578125 alpha:1];
        [myView addSubview: myTableView];


I tried like this it is not working.
- (NSInteger)tableView:(UITableView *)tableView  numberOfRowsInSection:(NSInteger)section
{
    if(section==0)
    {
        myTableView.editing = NO;
        myTableView.allowsSelectionDuringEditing = NO;
        return 3;
    }
    else if(section ==1)
    {
        myTableView.editing = NO;
        myTableView.allowsSelectionDuringEditing = NO;
        return 2;
    }
    else if(section==4)
    {
        myTableView.editing = YES;
        myTableView.allowsSelectionDuringEditing = YES;
        if(isEdit == YES)
        {
            if([editObject.contactList count]>0)
            {
                return [editObject.contactList count]+1;
            }
            else
            {
                return 1;
            }
        }   
        else if(isEdit == NO)
        {
            if([addContactList count]>0)
            {
                return [addContactList count]+1;
            }
            else
            {
                return 1;
            }
        }

    }
    else if(section==2)
    {
        myTableView.editing = NO;
        myTableView.allowsSelectionDuringEditing = NO;
        return 1;
    }
    else if(section==3)
    {
        myTableView.editing = NO;
        myTableView.allowsSelectionDuringEditing = NO;
        return 1;
    }
    return 0;
}
我在第四部分中得到了
+
按钮,但所有其他部分都被移到了右侧。

实现
-(UITableViewCellEditingStyle)tableView:(UITableView*)tableView editingStyleForRowAtIndexPath:(NSIndexPath*)对于您不希望编辑的部分中的行,indexPath
并返回
UITableViewCellEditingStyleNone

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the specified item to be editable.
return YES;
}

+图标不需要用于其他分区,只需要用于特定分区及其行。这很明显,但也要确保您已将AllowSelectionDuringEdit属性设置为true。您可以在代码或xib设计器中执行此操作。详情如下: