![](/img/trans.png)
[英]iOS: Universal app won't rotate, never calls willRotateToInterfaceOrientation
[英]IOS7 Xcode 5 universal app won't rotate on iphone, but will on ipad
我擁有一個最初為ipad打造的應用程序,並且我正在使其成為通用應用程序。 總的來說,我已經使整個應用程序正常工作,所有功能都在正常工作並且大小正確。 除了在iPhone上,該應用不會向任何方向旋轉外,它始終處於縱向模式。
這是我所擁有的:
再次,這在ipad上非常完美,我對ios開發還是很陌生。 我實際上有一個朋友開發了ipad應用程序,我將其用作深入研究ios的出發點,因此,我試圖將其轉變為通用應用程序,以使我的腳浸濕。
任何指針將不勝感激。 我正在用這個拔頭發。
(BOOL) shouldAutorotate{
return YES;
}
- (NSUInteger) supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationLandscapeRight; //you can choose either landscape orientation here
}
終於弄明白了。 它是UIImagePickerController。 由於某種原因,它對於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.