Search code examples
uitabbarcontrollertouch-up-inside

Touch Up Inside event not working after rotation of tab bar


I have a button in one of view controller of tab bar controller. All set up in storyboard. I registered action method like this

- (IBAction)buttonPressed:(id)sender {
    NSLog(@"Button pressed");
}

The thing is that once I make left and top constraints (to force it stay in the right upper corner) touch up inside event stops working after I change rotation. So just open app in portrait mode - method is working. Change to landscape and I cannot tap button suddenly.

I've recreated problem in this easy example project.

Many thanks.


Solution

  • Just put the following code in you TabBarViewController class.

    - (void)viewDidLayoutSubviews
    {
        // fix for iOS7 bug in UITabBarController
        self.selectedViewController.view.superview.frame = self.view.bounds;
    }