FGallery-iPhone icon indicating copy to clipboard operation
FGallery-iPhone copied to clipboard

iOS 6 autorotation problem

Open macstens opened this issue 12 years ago • 10 comments

In

FGalleryViewController.m

  • (BOOL) shouldAutorotateToInterfaceOrientation

the autorotation-methods for its parent controller have been overridden, which has worked wonderful until the recent release of iOS6.

Unfortunately, the images can no longer be rotated when the supported rotations have been set to, for example, only portrait. It seems like the method does not override this behavior anymore.

Did someone came up with a solution for this?

macstens avatar Sep 25 '12 14:09 macstens

autorotation is posing a problem for me, as well. I'd love to get more clarity on the topic.

To add to your comment... The supported interface orientations in the plist appears to be subtractive, so you'd want to include all that your app uses. Then, in your app delegate, override application:supportedInterfaceOrientationsForWindow: to provide a default bitmask for child views of the UIWindow passed in. Finally, your view controllers should provide their own, specific bitmasks, as necessary, using the selector supportedInterfaceOrientations.

The issue I'm currently facing is the container view controllers such as UINavigationController and my own implementation of ViewDeck controller. Parent controllers take precedence and the hierarchy's orientation handling isn't 100% clear.

ccraigc avatar Oct 09 '12 18:10 ccraigc

I got the same issue. Any solution for iOS 6?

bagusflyer avatar Oct 20 '12 01:10 bagusflyer

Yes, the solution that I decided upon, and which others have mentioned, is to presentViewController with your gallery view rather than push to your navigationController. Then you can use the shouldAutorotate and supportedInterfaceOrientations within the presented controller to set the supported orientations. Your whole hierarchy has to agree if you push to navigationControllers.

ccraigc avatar Oct 20 '12 02:10 ccraigc

Thanks. I think this is not a perfect solution but I can use it for the time being and I'll continue to investigate the problem and let you know if I find a "perfect" solution.

在 2012年10月20日,上午10:02,ccraigc [email protected] 写道:

Yes, the solution that I decided upon, and which others have mentioned, is to presentViewController with your gallery view tater than push to your navigationController. Then you can use the shouldAutorotate and supportedInterfaceOrientations within the presented controller to set the supported orientations. Your whole hierarchy has to agree if you push to navigationControllers.

— Reply to this email directly or view it on GitHub.

bagusflyer avatar Oct 20 '12 02:10 bagusflyer

I know what you mean. To explain a little further, you can accomplish what you're after by subclassing UINavigationController and overriding those methods I mentioned by returning their visibleController's supported orientations. Problem I ran into then was forcibly rotating back when popping or pushing other viewsControllers. It seems to disregard those settings until a rotation change is received. If you can figure out the rest I'd be interested in the solution.

ccraigc avatar Oct 20 '12 02:10 ccraigc

Can you please explain a little bit more on how to fix this issue? Thanks.

shem8 avatar Oct 29 '12 07:10 shem8

Solved For iOS 6 use:

  • (BOOL) shouldAutorotate { return YES; }

and in appDelegate change

// [self.window addSubview:navigationController.view]; to [self.window setRootViewController:navigationController];

HDdeveloper avatar Nov 09 '12 09:11 HDdeveloper

Hey guys, I have a solution if you have a UITabBarController with UINavigationController sub views. The trick is to subclass UITabBarController, then set your UITabBarController to use this class. Inside this subclass, add:

- (BOOL)shouldAutorotate{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations{
    if([self.selectedViewController isKindOfClass:[UINavigationController class]]){
        UINavigationController *navController = (UINavigationController *)self.selectedViewController;
        if([navController.visibleViewController isKindOfClass:[FGalleryViewController class]]){
            return UIInterfaceOrientationMaskAll;
        }
    }
    return UIInterfaceOrientationMaskPortrait;
}

This will ensure that none of your views can rotate, except the FGalleryViewController.

a1phanumeric avatar Dec 10 '12 12:12 a1phanumeric

a1phanumeric your solution works but when you are in portrait mode on the gallery and come back to the previous viewcontroller (the one that pushed the FGalleryViewController) the view appears on portrait mode and all content is on the wrong place, is there a way that when you push the back button on the FGalleryViewController the content is displayed correct?

Thanks.

Miguel86 avatar May 30 '13 11:05 Miguel86

I have this weird issue in iOS 8.3. It works fine in portrait mode and then I rotate to landscape for first time. But When tap once (to got to full screen) in landscape it ![Uploading IMG_1417.PNG…](looks like this) goes to top this corner with portrait frame setting. And then again when I rotate it to portrait, it goes back to bottom with landscape frame setting. img_1418

Did it occur to someone else. How can it be fixed.

rptwsthi avatar May 21 '15 19:05 rptwsthi