I have an editable UITableView. By default the user can swipe and the Delete button will show up. I would like to hide some elements on my UITableView cell when th开发者_开发百科is occurs. How can I do this?
Oh c'mon:
tableView:willBeginEditingRowAtIndexPath:
...
Discussion
This method is called when the user swipes horizontally across a row; as a consequence, the table view sets its editing property to YES (thereby entering editing mode) and displays a Delete button in the row identified by
indexPath
. In this "swipe to delete" mode the table view does not display any insertion, deletion, and reordering controls. This method gives the delegate an opportunity to adjust the application's user interface to editing mode. When the table exits editing mode (for example, the user taps the Delete button), the table view callstableView:didEndEditingRowAtIndexPath:
.
Reference
And then throw some [[cell viewWithTag:<#View's tag number#>] setHidden:YES]
for your own views.
Try overriding the willTransitionToState method in your custom UITableViewCell. In particular you would be interested in the UITableViewCellStateShowingDeleteConfirmationMask state.
Couldn't you modify the pertinent elements of the – tableView:willBeginEditingRowAtIndexPath:
is called?
As soon as the user wants to editing something in his tableView
, this method gets called
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
if(editing){
// Entered Edit mode
// Show the new tableView and reload it.
}
else {
// End of edit mode
// Bring back the tableview and again reload it.
}
[super setEditing:editing animated:animated];
}
Update your UI in tableView:willBeginEditingRowAtIndexPath:
and Restore in tableView:didEndEditingRowAtIndexPath:
.
精彩评论