4

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 ?

madLokesh
  • 1,860
  • 23
  • 49
TienLe
  • 614
  • 2
  • 9
  • 33

5 Answers5

4

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

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;

}
abhishekkharwar
  • 3,529
  • 2
  • 18
  • 31
0
cell.contentView.exclusiveTouch = YES;
cell.exclusiveTouch = YES;

Also disable the multiple touch property from the tableView

self.tableView.multipleTouchEnabled = NO;
Utsav Parikh
  • 1,216
  • 7
  • 14
0

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.

Shruti
  • 1,849
  • 1
  • 13
  • 21
0

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.

Britto Thomas
  • 2,092
  • 1
  • 15
  • 28