iOS 6 rotation not working

旧巷老猫 提交于 2019-12-02 03:45:28

It seems you are confusing what to return in shouldAutorotate. Use the following code as an example.

Since iOS is making a call into your app's shouldAutorotate in response to an event from the accelerometer, it already knows the new orientation; if your app answers 'YES`, iOS could then check the current orientation against the list of supported ones, and come up with a decision without your app querying for the current orientation.

// iOS 6

- (BOOL)shouldAutorotate {
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}

Also, You can let the view controller that presents your modal view controller inform it of rotation. Use: presentViewController:animated:completion: to present the view controller. presentModalViewController:animated: is deprecated if by chance you are using it.

If you add application:supportedInterfaceOrientationsForWindow:, make sure to follow the code guideline below. The documentation states that if you implement supportedInterfaceOrientations on a VC it should override the app delegate. However, people have noticed it makes a difference as to how you add the rootViewController to the main window.

Use:

window.rootViewController = viewController

instead of:

[window addSubview:viewController.view];
fibnochi

I did this in this way

-(BOOL) shouldAutorotate{
    return YES;
}

-(NSUInteger) supportedInterfaceOrientations{
    if ([self.visibleViewController isKindOfClass:[ZoomPictureViewController class]]) {
        return UIInterfaceOrientationMaskAll;
    }
    return UIInterfaceOrientationMaskPortrait;
}

Make sure you've clicked the orientation buttons in Xcode to enable the orientations you want and return the orientations in supportedInterfaceOrientations method.

Hot Licks

First, make sure you've clicked the orientation buttons in Xcode to enable the orientations you want. Then spend a few hours Googling all the bugs and problems people have encountered with iOS 6. And a few more hours experimenting with various techniques.

This post contains a few clues, but is far from the final word in the matter.

Note in particular that you now must identify the "root view controller" and concentrate most (but not all) of the rotation controls there, vs implementing it in each view controller.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!