[英]Delete button disappeared on scrolling in edit mode of UITableview
I am facing the issue when I scroll the tableview in edit mode. 我在编辑模式下滚动tableview时遇到问题。 It's because of reusability of cells.
这是因为细胞的可重用性。 I followed the link- UITableView in Edit Mode - Delete Button Dissapears on Scroll
我按照编辑模式中的链接-UITableView - 在滚动上删除按钮消失
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
方法-(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];
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.