开发者

iPhone Device Orientation Bug

开发者 https://www.devze.com 2023-01-21 01:49 出处:网络
I\'m stuck since few days with a weird issue. I\'ve been looking for a solution on Google, and I don\'t see anyone having the same bug.

I'm stuck since few days with a weird issue. I've been looking for a solution on Google, and I don't see anyone having the same bug.

My application doesn't want to rotate. I'm using several viewController, implemented the shouldAutoRotateToOrientation method but the view controllers don't want to rotate.

I've done the debug, but the the method

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return toInterfaceOrientation == UIInterfaceOrientationPortrait;
}

is called only once, when the view load, with the UiDeviceOrientationPortr开发者_开发问答ait. When I change my iphone orientation, it doesn't call this method in any Controller.

In the info.plist i put in the "Supported Interface Orientation" every orientation, but it didn't change anything.

I'm using the Three20 classes, for some viewControllers but not the TTNavigator.I'm also using the ZXIng widget. My app is a tabBarApplication. I know a tabBar can rotate only if all the viewContrllers of the tabBar can also rotate. But the views i Want to be able to rotate are in modals view, or MPMoviePlayer. Even the videos stay stucked in Portrait.

Thank you for your help.

Ed


Your shouldAutorotateToInterfaceOrientation is only returing YES for UIInterfaceOrientationPortrait.

If you want it to rotate to every orientation, you need to tell it YES for every orientation, not just portrait.

Try this :

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


My probllem was that in the aaplicationDidFinishLauching, i was doing:

[window addSubview:_zxingController.view];
[window addSubview:myTabBarController.view];

So it took the zxing View as the base view (which is a view that can't rotate). That's why it didn't event try to rotate by MyTabBarController by calling shouldAutorotateToInterfaceOrientation.

So now i did:

[window addSubview:myTabBarController.view];
[window insertSubView:_zxingController.view atIndex:0];

problem solved.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号