刪除所有選定行我知道這個電話,將刪除選定的行:的Objective-C從UITableView中
[tableView deselectRowAtIndexPath:indexPath animated:YES];
我的問題是,我該如何刪除所有選定的行?因爲我有多個選擇。
感謝,
刪除所有選定行我知道這個電話,將刪除選定的行:的Objective-C從UITableView中
[tableView deselectRowAtIndexPath:indexPath animated:YES];
我的問題是,我該如何刪除所有選定的行?因爲我有多個選擇。
感謝,
如果你問行取消你可以做這樣的:
NSArray *selectedIndexPaths = [tableView indexPathsForSelectedRows];
[tableView beginUpdates];
[selectedIndexPaths enumerateObjectsUsingBlock:^(NSIndexPath *selectedIndexPath, NSUInteger idx, BOOL * _Nonnull stop) {
[tableView deselectRowAtIndexPath:selectedIndexPath animated:NO];
}];
[tableView endUpdates];
這沒有奏效,所選行仍保持不變。 – user979331
@ user97931我剛剛在一個測試項目上檢查了這個方法,一切正常。你可以分享你的代碼,以便我們看到問題出在哪裏...... – Seliver
您可以使用deleteRowsAtIndexPaths(_:withRowAnimation :)與選定indexPaths。
此外,你必須從你的數據源中刪除你的對象。
OP需要取消選擇不刪除它們的行。 –
使用此:
[self.tableView reloadData];
我認爲唯一的辦法是遍歷所有行和取消他們! –
'indexPathsForSelectedRows'返回'NSIndexPath'的'NSArray'。那麼循環和取消選擇行呢? – Larme