gpt4 book ai didi

ios - 分组的UITablleview不可编辑单元格缩进

转载 作者:行者123 更新时间:2023-12-01 19:01:28 25 4
gpt4 key购买 nike

我正在处理包含带有编辑/删除功能的分组部分UITableView之一的应用程序。 Tableview看起来像这样

-(IBAction) EditTable:(id)sender 
{
if (self.editing)
{
[super setEditing:NO animated:NO];
[libtable setEditing:NO animated:NO];
[libtable reloadData];
[tabledit setTitle:@"Edit" forState:UIControlStateNormal];
}
else
{
[super setEditing:YES animated:YES];
[libtable setEditing:YES animated:YES];
[libtable reloadData];
[tabledit setTitle:@"Done" forState:UIControlStateNormal];
}}

- (void)tableView:(UITableView *)aTableView commitEditingStyle:
(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{

if (editingStyle == UITableViewCellEditingStyleDelete)
{
[self delete];
}
}

在每个部分的第一行,我已使用此方法禁用了编辑模式:
-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return indexPath.row > 0;}

它工作正常,但您可以在此图中看到:

当我单击编辑模式时,由于不可编辑模式,每个部分的第一行都不会移到右侧。与其他行一样,在编辑按钮的单击右侧也需要这些0索引行。我没有找到解决此问题的任何方法。如果有人对此概念有所了解,请帮助我。

提前致谢。

最佳答案

尝试如下

  - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{

if(indexPath.row == 0) //for each section of first row return UITableViewCellEditingStyleNone
return UITableViewCellEditingStyleNone;

return UITableViewCellEditingStyleDelete;


}

我忘了看你的 -(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
  //you may comment this method
-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES; //return for every cell as editable
}

如果您在编辑模式下运行并运行,它将得到如下所示

关于ios - 分组的UITablleview不可编辑单元格缩进,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22657865/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com