简体   繁体   English

iPhone设备方向错误

[英]iPhone Device Orientation 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. 我一直在寻找Google上的解决方案,但没有人遇到相同的错误。

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. 我正在使用几个viewController,实现了shouldAutoRotateToOrientation方法,但是视图控制器不想旋转。

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 UiDeviceOrientationPortrait. 当视图加载时,仅使用UiDeviceOrientationPortrait调用一次。 When I change my iphone orientation, it doesn't call this method in any Controller. 当我更改iphone的方向时,它不会在任何Controller中调用此方法。

In the info.plist i put in the "Supported Interface Orientation" every orientation, but it didn't change anything. 我在info.plist中的每个方向都输入了“ Supported Interface Orientation”,但它没有任何改变。

I'm using the Three20 classes, for some viewControllers but not the TTNavigator.I'm also using the ZXIng widget. 我正在使用Three20类,用于某些viewControllers,但不用于TTNavigator。我也在使用ZXIng小部件。 My app is a tabBarApplication. 我的应用程序是一个tabBarApplication。 I know a tabBar can rotate only if all the viewContrllers of the tabBar can also rotate. 我知道,只有tabBar的所有viewContrllers也可以旋转时,tabBar才能旋转。 But the views i Want to be able to rotate are in modals view, or MPMoviePlayer. 但是我希望能够旋转的视图是模态视图或MPMoviePlayer。 Even the videos stay stucked in Portrait. 甚至视频也停留在“人像”中。

Thank you for your help. 谢谢您的帮助。

Ed 埃德

Your shouldAutorotateToInterfaceOrientation is only returing YES for UIInterfaceOrientationPortrait. 您的shouldAutorotateToInterfaceOrientation仅对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: 我的问题是在aaplicationDidFinishLauching中,我正在做:

[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). 因此,将zxing视图作为基本视图(该视图无法旋转)。 That's why it didn't event try to rotate by MyTabBarController by calling shouldAutorotateToInterfaceOrientation. 这就是为什么它没有事件通过MyTabBarController尝试通过调用shouldAutorotateToInterfaceOrientation来旋转的原因。

So now i did: 所以现在我做到了:

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

problem solved. 问题解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM