Re: [問題] reloadRowsAtIndexPath exception
※ 引述《uranusjr (←這人是超級笨蛋)》之銘言:
: 當 textFieldShouldEndEditing 被呼叫時, text field 還沒有結束編輯
: 這時候你還不能對包含它的 cell 進行 reload (正確來說應該是不能 remove)
: 不然程式就...嗯, 失去了 consistency
: 解決方法是不要在 textFieldShouldEndEditing: 直接呼叫 reload
: 而是要在它「結束之後」排定一個 reload 事件
: 最簡單的解法(之一)是用 GCD 塞一個 async call
: http://stackoverflow.com/questions/13907335/
感謝解說
我把code改成
- (BOOL) textFieldShouldEndEditing:(UITextField *)textField
{
NSIndexPath *AlertPath = [NSIndexPath indexPathForRow:1 inSection:0];
NSArray *myArray = [NSArray arrayWithObjects:AlertThresholdPath, nil];
dispatch_async(dispatch_get_main_queue(), ^{
[self.functionTable reloadRowsAtIndexPaths:myArray
withRowAnimation:UITableViewRowAnimationAutomatic];
});
return YES;
}
可是出現了資料不同步的問題
Initail textField text : 50
輸入51 return後
在 reload時, 讀取的textField text 仍為50
再輸入52 return後 , reload 讀取為51, 會有延遲一次編輯的狀況
請問該怎麼處理呢?
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 60.251.44.30
推
11/04 16:01, , 1F
11/04 16:01, 1F
→
11/04 16:06, , 2F
11/04 16:06, 2F
推
11/04 16:49, , 3F
11/04 16:49, 3F
→
11/04 17:21, , 4F
11/04 17:21, 4F
討論串 (同標題文章)
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章