iphone - 如何设置iPhone中特定部分的编辑是"is"

标签 iphone objective-c uitableview

我已经在.h文件中声明了UITableView。我在表格 View 中有 5 个部分,现在我需要仅为第 4 部分设置 tableview.editing= yes 。

如何在第 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;
}

我在第四部分中看到了 + 按钮,但所有其他部分都移到了右侧。

最佳答案

实现

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

关于iphone - 如何设置iPhone中特定部分的编辑是"is",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2839280/

相关文章:

IOS - 如何使用自动布局获得可滚动的 TableView 标题

iphone - 如何在ios中的UIWebView中闪烁文本?

android - 移动开发推荐

ios - APN 自定义通知声音问题

ios - Swift 无法为 UITextField 调用添加目标

具有额外填充的 UITableViewCell 内的 iOS Autolayout 2 多行 UILabel

iphone - 如何在允许的一百个临时安装之一上安装应用程序?

iphone - coredata 应用程序目录

ios - 如果 physicsBody.dynamic 属性为 NO,则两个物理体不接触

ios - 隐藏单元格中的自定义 UITableviewcell 更新