4
votes

I have a UITableView:

Cell 1: Button 1->push to view controller A

Cell 2: Button 2->push to view controller B

It works fine. However, when I try to hold and press two buttons at the same time, my app receives following warning:

nested push animation can result in corrupted navigation bar. Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.

How should I disable multi click button on cell ?

5
There is property in IB .. Selection options is there you can select single selection option.Ashok Londhe
hi.. you have not replied.Ashok Londhe
@AshokLondhe: I'm so sorry. I just go out. I've tried to set single selection. But it didn't work too.TienLe
there are two options 1) Selection 2)Editing. Set this two option and try. i am sure your problem getting solved.Ashok Londhe

5 Answers

4
votes

You just need to disable the button while pushing to another View Controller. You can create category ofUINavigationController for pushing to another view Controller. Make sure that you enable the button before coming back to current viewController

@interface UINavigationController (CompletionHandler)

- (void)pushViewController:(UIViewController *)viewController
              animated:(BOOL)animated
            completion:(void (^)(void))completion;

@end




@implementation UINavigationController (CompletionHandler)
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated completion:(void (^)(void))completion {
[CATransaction begin];
[CATransaction setCompletionBlock:completion];
[self pushViewController:viewController animated:animated];
[CATransaction commit];
}


@end

Call the below code for pushing to another ViewController

[self.navigationController pushViewController:ControllerObj animated:YES completion:^{
        btn.userInteractionEnabled = NO; // Your Button Object
        NSLog(@"COMPLETED");
    }];
1
votes

You have to set exclusive touch on each cell's button.

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    // Get your cell

    cell.button.exclusiveTouch = YES;

    return cell;

}
0
votes

if above method is not working then when one button is clicked you can disable the interaction with the cell

cell.userInteractionEnabled = NO;

Later as per your need or in viewWillAppear enable the same.

0
votes
cell.contentView.exclusiveTouch = YES;
cell.exclusiveTouch = YES;

Also disable the multiple touch property from the tableView

self.tableView.multipleTouchEnabled = NO;
0
votes

Change your button's IBAction forControllEvent as UIControlEventTouchDown.

if you use storyboard cell hook up your buttons action by changeing touchUpInside to touchDown.

or

[YOUR_BUTTON addTarget:self action:@selector(YOUR_IBACTION:) forControlEvents:UIControlEventTouchDown];

This will prevent button touch and holding. and this Action will call push immediatly at your touch.