我有和应用程序最初是为ipad而构建的,我正在使它成为一个通用的应用程序。我已经让整个应用程序正常工作,通用,所有功能都正常工作和大小。除了在iPhone上,应用程序不会向任何方向旋转,它将保持纵向模式。
这就是我所拥有的:
同样,这在ipad上运行得很完美,而且我对ios开发很新。我实际上有一个朋友开发ipad应用程序和我;我用它作为我的步骤点挖掘ios,因此我试图把它变成一个通用的应用程序让我的脚湿。
任何指针都会非常感激。我正用这个把头发拉出来。
答案 0 :(得分:0)
(BOOL) shouldAutorotate{
return YES;
}
- (NSUInteger) supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationLandscapeRight; //you can choose either landscape orientation here
}
答案 1 :(得分:0)
终于搞清楚了。这是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