删除button在UITableview的编辑模式下滚动消失
我在编辑模式下滚动tableview时遇到问题。 这是因为细胞的可重用性。 我在编辑模式下的链接UITableView – 滚动删除buttonDissapears
没有从这一点。
这是我的代码片段 –
- (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; }
那么任何人的build议或build议如何解决这个问题?
谢谢。
更改-(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]; } }
- (BOOL)tableView:(UITableView *)tableview shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath { return YES; // return yes }
现在运行你的程序,让我知道发生了什么?
编辑
从这里得到这个演示。 好的exlanation给出