I’m trying to show and hide a subview when the UITableview is in editing mode and while it’s showing the delete button (the entire editing and deleting process, not just editing), then make it disappear when it goes back into normal mode.
I’m really close to getting it the way I want, but every time you click on a “delete” button in the cell, it makes my view disappear, when I don’t want it to disappear until the user exits edit mode completely.
I’m trying to use the delegate method - (void)willTransitionToState:(UITableViewCellStateMask)state but I’m getting an error when I call super:
- (void)willTransitionToState:(UITableViewCellStateMask)state {
[super willTransitionToState:state];
if ((state & UITableViewCellStateShowingEditControlMask)) {
clear.alpha = 1.0;
}
}
The error is a common one, but I can’t seem to find a solution:
No visible @interface for ‘UITableViewController’ declares the
selector ‘willTransitionToState:’
I don’t get the error if I don’t call super, but the method never gets called either.
I’ve also tried using setEditing, but the view that I want to stay visible during the entire editing/deleting process disappears when the delete button is tapped, deleting the cell, but still in editing mode
You need to call that method (willTransitionToState:) in your custom tableview cell. it isn’t a method that is recognized in a UITableViewController class. if you call willTransitionToState: in the .m file if your custom tableview cell class, it should work. Just make sure that cell class has the ivar ‘clear’ defined (which you seem to have, based on the code you provided). Also check out the layoutSubviews method if you’d like to do things like prevent the cells from indenting content while editing.