[問題] 移動 TableView Cell 畫面更新問題

看板MacDev作者 (Objective-D)時間11年前 (2013/09/25 12:55), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/1
因為客戶的需求,移動編輯TableView cell並沒有增加 button 在畫面上, 而是使用 UILongPressGestureRecognizer 的手勢加在各個 cell 上。 移動時會實作 - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath { // Data source 資料互換.... // .... // 結束後 [tableView setEditing:NO animated:YES]; // *1 } 在這 delegate method 執行 結束編輯狀態, 當有跨越 tableview 上看不見的 cell (如從最上方 index 0,拖到最下方 index 49), 結束移動的 cell 右方的 accessoryView 無法從編輯狀態的 icon 恢復成箭頭 icon。 我想是不是不適合在這 delegate method 下 setEditing:animated:? 我目前想到的解法有兩種,但不確定會有什麼影響。 1. 在 *1 後面補上 [tableView reload]; 缺點:icon 轉換的動畫,因為 tableView reload 的刷新,反而看不出效果。 2. 利用 delay 的方式 - (void)endMovingCell { [myTableView setEditing:NO animated:YES]; } 用這行取代上面 *1 [self performSelector:@selector(endMovingCell) withObject:nil afterDelay:0.01]; PS: 秒數我設0還是正常,挺詭異... 目前是用2的解法。 我的疑問是,這樣會有什麼潛在問題嗎? 翻了一下 Apple文件,沒找到跟 didMoveRowAtIndexPath 相關的 delegate method... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.163.16.106

09/25 14:04, , 1F
http://ppt.cc/rC5R 看看有沒有你要的
09/25 14:04, 1F
文章代碼(AID): #1IGcovoM (MacDev)
文章代碼(AID): #1IGcovoM (MacDev)