TTPhotoViewController rotate image but not the navigatione and tool bar

368 views Asked by At

I have made a subclass of TTPhotoViewController, wich when I Rotate iPhone also the current image is rotated but NOT The navigation bar and the toolbar (the bar with prev and next button). In my subclass I have overide the shouldAutorotateToInterfaceOrientation: method:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {   
    return  YES;
}

I've tried to overide willRotateToInterfaceOrientation:duration: e set up a breakpoint inside but seem that this method is never called.

2

There are 2 answers

0
Luca Bernardi On BEST ANSWER

I solved as follow:

TTPhotoViewController was within a TabBarController and by default TabBarController doesn't return YES for shouldAutorotateToInterfaceOrientation. So just subclass TabBarController and do something like that:

@implementation CustomTabBarController

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
    return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}

@end

I add a small detail: in my firts attempt to rotate the interface i've found that the deviceOrientationDidChange: in TTScrollView.m was commeted out, this is done because if you decomment this code the scroll view have a strange behaviour on landascape rotation.

0
k-thorat On

Make sure all your view controllers i.e. Parent view controllers are allowing rotations.. most likely it is happening because one or more view controller is not returning TRUE for shouldAutorotateToInterfaceOrientation