我已经在.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/