我的应用程序是通用的。 iPad只是风景(左或右); iPhone只是肖像。
一切正常对于iPhone编码,但在尝试呈现UIImagePickerController时我在iPad上遇到以下错误。
Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'preferredInterfaceOrientationForPresentation must return a supported interface orientation!'
这是我的设置......
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if(isPad()){
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}else{
return UIInterfaceOrientationMaskPortrait;
}
}
- (NSUInteger) supportedInterfaceOrientations
{
if(isPad()){
return UIInterfaceOrientationMaskLandscape;
}else{
return UIInterfaceOrientationMaskPortrait;
}
}
-(BOOL)shouldAutorotate{
return NO;
}
-(UIInterfaceOrientation) preferredInterfaceOrientationForPresentation {
if(isPad()){
return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight;
}else{
return UIInterfaceOrientationPortrait;
}
}
- (NSUInteger) supportedInterfaceOrientations
{
if(isPad()){
return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight;
}else{
return UIInterfaceOrientationMaskPortrait;
}
}
-(BOOL)shouldAutorotate{
return NO;
}
-(UIInterfaceOrientation) preferredInterfaceOrientationForPresentation {
if(isPad()){
return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight;
}else{
return UIInterfaceOrientationPortrait;
}
}
UIImagePicker(在iPad中)是由UIPopoverController提供的视图控制器呈现的
答案 0 :(得分:0)
在UIImagePickerController
类别中使用
-(NSUInteger)supportedInterfaceOrientations {
if(isPad()){
return UIInterfaceOrientationMaskLandscape;
}
else{
return UIInterfaceOrientationMaskPortrait;
}
}
答案 1 :(得分:0)
原来你必须在iPad上的popover中呈现UIImagePickerController。
答案 2 :(得分:0)
UIImagePickerController类仅支持纵向模式。见Apple docs