[英]IOS7 Xcode 5 universal app won't rotate on iphone, but will on ipad
I have and app that was initially built for ipad and i'm in the midst of making it a universal app. 我拥有一个最初为ipad打造的应用程序,并且我正在使其成为通用应用程序。 I've got the entire app working, universally, all functionality is working and sized correctly.
总的来说,我已经使整个应用程序正常工作,所有功能都在正常工作并且大小正确。 Except that on the iphone the app won't rotate in any direction, it stays in portrait mode.
除了在iPhone上,该应用不会向任何方向旋转外,它始终处于纵向模式。
Here's what i've got: 这是我所拥有的:
Again, this works perfect on the ipad and i'm very new to ios development. 再次,这在ipad上非常完美,我对ios开发还是很陌生。 i Actually had a friend develop the ipad app and i;m using it as my step-off point to dig into ios, thus i'm trying to turn it into a universal app to get my feet wet.
我实际上有一个朋友开发了ipad应用程序,我将其用作深入研究ios的出发点,因此,我试图将其转变为通用应用程序,以使我的脚浸湿。
Any pointers would be much appreciated. 任何指针将不胜感激。 I'm pulling my hair out with this.
我正在用这个拔头发。
(BOOL) shouldAutorotate{
return YES;
}
- (NSUInteger) supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationLandscapeRight; //you can choose either landscape orientation here
}
Finally got this figured out. 终于弄明白了。 It was the UIImagePickerController.
它是UIImagePickerController。 For some reason it worked perfect for the ipad but i needed to overwrite it for the iphone.
由于某种原因,它对于ipad来说非常完美,但是我需要为iphone覆盖它。
#import "UIImagePickerController+rotation.h"
@interface UIImagePickerController (private)
- (BOOL)shouldAutorotate;
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation;
- (NSUInteger)supportedInterfaceOrientations;
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
@end
@implementation UIImagePickerController (Private)
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll;
}
- (BOOL)shouldAutorotate {
return UIInterfaceOrientationMaskAll;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
return UIInterfaceOrientationPortrait;
}
else
{
return UIInterfaceOrientationLandscapeRight;
}
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
@end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.