簡體   English   中英

在UITableview的編輯模式下滾動時刪除按鈕消失

[英]Delete button disappeared on scrolling in edit mode of UITableview

我在編輯模式下滾動tableview時遇到問題。 這是因為細胞的可重用性。 我按照編輯模式中的鏈接-UITableView - 在滾動上刪除按鈕消失

什么都沒有。

這是我的代碼片段 -

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

滾動時刪除按鈕行為

那么任何人如何解決該問題的任何建議或建議?

謝謝。

更改-(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];
    }
}
- (BOOL)tableView:(UITableView *)tableview shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath 
{
   return YES; // return yes
}

現在運行你的程序,讓我知道發生了什么?

編輯

這里獲取此演示。 很好的exlanation

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM