【问题标题】:Delete button disappeared on scrolling in edit mode of UITableview在 UITableview 的编辑模式下滚动时删除按钮消失
【发布时间】:2017-03-28 05:24:48
【问题描述】:

当我在编辑模式下滚动表格视图时,我遇到了这个问题。这是因为细胞的可重用性。我跟着链接- UITableView in Edit Mode - Delete Button Dissapears on Scroll

从中一无所获。

这是我的代码 sn-p-

- (void)setEditing:(BOOL)editing
      animated:(BOOL)animated
{
   [super setEditing:editing animated:animated];
   [tableView setEditing:editing animated:animated];
   [tableView setAllowsMultipleSelectionDuringEditing:editing];

}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
   return UITableViewCellEditingStyleDelete;
}


- (BOOL)tableView:(UITableView *)tableview shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath 
{
   return NO;
}


- (BOOL)tableView:(UITableView *)tableview canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
   return YES;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];

   if (cell == nil)
    {
      cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];

    }

 [cell setEditingAccessoryType:UITableViewCellAccessoryDetailDisclosureButton];

 cell.textLabel.text=[NSString stringWithFormat:@"%ld",indexPath.row+1];
 cell.detailTextLabel.text=@"";


 cell.clipsToBounds = YES;
 return cell;
}

那么任何人的任何建议或建议如何解决该问题?

谢谢。

【问题讨论】:

  • 从哪里可以看到 OP 也面临同样的问题,并且对于同样的问题没有可用的解决方案。
  • @agent_stack 操作?我也在寻找同样的东西。看看有没有人解决了这个问题。
  • OP 表示 原始发帖人 表示是谁发起了讨论,就像这里你是 OP。
  • 尝试用强属性声明 tableview 属性...我遇到了这种问题,但当我用强而不是弱更改 tableview 属性时,它工作正常
  • @agent_stack 好的。我用谷歌搜索,发现那个链接有同样的问题。

标签: ios objective-c uitableview


【解决方案1】:

-(void)setEditing:(BOOL)editing animated:(BOOL)animated方法改成这样:

- (void)setEditing:(BOOL)editing animated:(BOOL)animated{
    _myTV.allowsMultipleSelectionDuringEditing = NO;
    [super setEditing:editing animated:animated];

    if(editing) {
        [_myTV setEditing:YES animated:YES];
    } else {
        [_myTV setEditing:NO animated:YES];
    }
}

【讨论】:

  • 你拯救了我的一天。美丽。结论:_myTV.allowsMultipleSelectionDuringEditing = NO; // 单选。和 _myTV.allowsMultipleSelectionDuringEditing = 编辑; //用于多选。
  • 是的,当然。完成了:)
  • @Amir Khan 谢谢好友。
【解决方案2】:
- (BOOL)tableView:(UITableView *)tableview shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath 
{
   return YES; // return yes
}

现在运行你的程序,让我知道发生了什么?

编辑

here 获取此演示。给出了很好的解释

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多