我有一個UITableview,我把它放在一個JASidePanel控制器(https://github.com/gotosleep/JASidePanels)我已經在我的init方法中設置了委託和數據源,並且我已經實現了canEditRowAtIndexPath方法,並且在我滑動時正在調用它們在tableview單元格上,但沒有任何事情發生。我查看了其他問題,並已實施所有建議,但無法顯示刪除按鈕。有誰知道什麼會導致這種行爲?UITableViewCell刪除按鈕不出現
0
A
回答
7
您必須實施tableView:editingStyleForRowAtIndexPath:
委託方法和tableView:commitEditingStyle:forRowAtIndexPath:
數據源方法。沒有這些,刪除將不會出現在單元格中。
我假設您從tableView:canEditRowAtIndexPath:
數據源方法(至少對於相應的行)返回YES
。
1
您是否嘗試過使用此類自己的刪除單元格的方法?
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (UITableViewCellEditingStyleDelete) {
int k = [[tempArray objectAtIndex:indexPath.row] intValue];
//Remove object from index 'k'.
}
}
它可能會幫助你。
謝謝。
0
在刷新TableViewCell時對UITableView執行刪除操作。我們必須執行以下三種方法: -
此方法將在滑動TableViewCell時顯示刪除按鈕。
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView
editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [indexPath row];
NSUInteger count = [posts count];
if (row < count) {
return UITableViewCellEditingStyleDelete;
} else {
return UITableViewCellEditingStyleNone;
}
}
當用戶刪除TableViewCell的刷卡及刷行的行這種方法被稱爲將在敲擊按鈕,刪除被刪除。
- (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [indexPath row];
NSUInteger count = [posts count];
if (row < count) {
[posts removeObjectAtIndex:row];
}
}
最後調用此方法在刪除行後更新表視圖。
- (void)tableView:(UITableView *)tableView
didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath {
[self updateViewTitle];
[tableView reloadData];
}
相關問題
- 1. 刪除按鈕不會出現在UITableViewCell
- 2. Unslide刪除按鈕的UITableViewCell
- 3. UITableViewCell,刪除按鈕框架?
- 4. 刪除UITableViewCell無刪除按鈕?
- 5. UITableView刪除按鈕不出現
- 6. UITableViewCell刷卡,但沒有出現刪除按鈕
- 7. 防止UITableViewCell左移,刪除按鈕出現在編輯表
- 8. 當「刪除」按鈕出現時,UITableViewCell重新組織子視圖
- 9. 無法從UITableView中刪除行(從不出現刪除按鈕)
- 10. UITableViewCell的自定義刪除按鈕
- 11. 如何從UITableViewCell中刪除按鈕?
- 12. 如何顯示左刪除按鈕UITableViewCell
- 13. 將「刪除」按鈕添加到UITableViewCell
- 14. 更改默認刪除按鈕UITableViewCell
- 15. UITableViewCell的刪除按鈕動畫
- 16. 向UiTableViewCell添加一個刪除按鈕
- 17. jQuery Javascript HTML 5導出按鈕不會出現並刪除其他按鈕
- 18. 當出現刪除按鈕時重新計算自定義UITableViewCell的高度
- 19. 單擊自定義刪除按鈕時刪除UITableViewCell
- 20. 如何在編輯UITableViewCell時刪除刪除按鈕?
- 21. 自定義UITableViewCell刪除按鈕不顯示
- 22. UITableViewCell,顯示輕掃式刪除按鈕,不用刷卡
- 23. UITableViewCell子類:刪除並重新排序按鈕不顯示
- 24. 按鈕不出現
- 25. TTLauncherView刪除刪除按鈕
- 26. 刪除按鈕不工作
- 27. 刪除按鈕
- 28. 刪除按鈕
- 29. 刪除按鈕
- 30. 刪除按鈕
我終於明白了這一點。我選擇了這個答案,因爲所有你需要做的就是實現這兩個方法,它的工作原理。我已經實現了這兩種方法,但刪除按鈕被隱藏在JASidePanel的中心面板控制器下面...我只需要縮小tableview的寬度就可以了。 – AFraser 2013-03-18 15:05:42
@AFraser - 實際上,您的評論幫助我回答了我的問題自己的問題,因爲我的問題非常相似(主視圖(在自定義拆分視圖控制器中)的右側被詳細視圖遮擋)。我肯定會建議把它作爲答案,因爲你的問題確實提到了JASidePanel控制器。 – Animal451 2014-02-05 08:21:19