您的位置:首页 > 产品设计 > UI/UE

IOS 横屏中添加UIImagePickerController获取系统图片

2015-03-25 18:26 651 查看
今天写ipad的项目,然后需要调用系统相册选择图片,然后用了UIImagePickerController ,崩溃了,后来查了一下,UIImagePickerController只支持竖屏,但是。。。

我竟然找到了一个解决的方法:

这是因为 UIImagePickerController只支持竖屏的原因。
解决:

1、在AppDelegate.m中添加

?
1
2
3
4
5
#if __IPAD_OS_VERSION_MAX_ALLOWED >= __IPAD_6_0
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return UIInterfaceOrientationMaskAll;
}
#endif


这样一般的就解决问题了,再不行话继续
在该viewController和上一层的viewController中添加

?
1
2
3
4
5
6
7
8
9
10
11
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation ==  UIInterfaceOrientationLandscapeLeft || interfaceOrientation ==  UIInterfaceOrientationLandscapeRight );
}

-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}

- (BOOL)shouldAutorotate {
return YES;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: