簡體   English   中英

我怎么知道UITableView何時顯示插入/刪除控件?

[英]How can I know when UITableView is displaying Insertion/Deletion controls?

情況1.我滑動以刪除一行。 表進入編輯模式,但顯示插入/缺失控制。

在此處輸入圖片說明

情況2。我按一個按鈕進入編輯模式,表格進入編輯模式, 顯示“插入/刪除”控件。

在此處輸入圖片說明

如何以編程方式區分這兩種情況?

要知道是tableview's edit還是insert哪個operationcommitted則可以使用UITableView delegate方法知道它

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(editingStyle == UITableViewCellEditingStyleDelete)
    {
       //delete operation
    }
    else if(editingStyle == UITableViewCellEditingStyleInsert)
    {
       //insert operation
    }
}

要知道tableview是否處於編輯狀態,請使用UITableView's editing property

if ([tableView isEditing]) 
{
   //TableView in editing mode so do any remaining operation need to be done
}
else
{
   //TableView in not in editing mode
}

暫無
暫無

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

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