在 UITableview 的编辑模式下滚动时删除按钮消失 [英] Delete button disappeared on scrolling in edit mode of UITableview

查看:29
本文介绍了在 UITableview 的编辑模式下滚动时删除按钮消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在编辑模式下滚动 tableview 时遇到了这个问题.这是因为细胞的可重用性.我按照链接-

那么任何人对如何解决该问题有任何建议或建议吗?

谢谢.

解决方案

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

- (void)setEditing:(BOOL)editing animation:(BOOL)animated{_myTV.allowsMultipleSelectionDuringEditing = NO;[超级集编辑动画:动画];如果(编辑){[_myTV setEditing:YES 动画:YES];} 别的 {[_myTV setEditing:NO 动画:YES];}}

I am facing the issue when I scroll the tableview in edit mode. It's because of reusability of cells. I followed the link- UITableView in Edit Mode - Delete Button Dissapears on Scroll

Got nothing from that.

Here is my code snippet-

- (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;
}

So any recommendation or suggestion from anyone how to resolve that issue?

Thank you.

解决方案

Change -(void)setEditing:(BOOL)editing animated:(BOOL)animated method into this:

- (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];
    }
}

这篇关于在 UITableview 的编辑模式下滚动时删除按钮消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆