IPAD下使用相册横屏异常的解决
来源:互联网 发布:微云for mac 编辑:程序博客网 时间:2024/05/22 02:13
原因大致是由于UIImagePickerController默认支持的是竖屏的原因,实现原理在打开相册前设置屏幕可翻转,关闭相册后设置为横屏模式
解决步骤
1,为 UIImagePickerController 添加类别如下
@interface UIImagePickerController (LandScapeImagePicker)
- (BOOL)shouldAutorotate;
- (NSUInteger)supportedInterfaceOrientations;
@end
#import "UIImagePickerController+LandScapeImagePicker.h"
@implementation UIImagePickerController (LandScapeImagePicker)
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
returnUIInterfaceOrientationMaskAll;
}
@end
同时在打开相册控制类中添加如下控制代码
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info
{
bAlbumListViewStatus =NO;
[picker dismissViewControllerAnimated:YEScompletion:nil];
UIImage *image = [infoobjectForKey:UIImagePickerControllerEditedImage];
//[self uploadImageWithImage:image];
}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
bAlbumListViewStatus =NO;
[picker dismissViewControllerAnimated:NOcompletion:nil];
}
弹出相册的地方代码修改如下
UIImagePickerController *picker = [[UIImagePickerControlleralloc] init];
picker.delegate = self;
picker.sourceType = sourceType;
picker.allowsEditing = YES;
bAlbumListViewStatus =YES;//
[selfpresentViewController:picker animated:YEScompletion:nil];
2,在app delegate里添加方向支持
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (bAlbumListViewStatus)//全局变量,定义是否打开相册
returnUIInterfaceOrientationMaskAll;
else
returnUIInterfaceOrientationMaskLandscapeLeft;
}
完成如上后即可解决了
- IPAD下使用相册横屏异常的解决
- 解决在 iPad 的横屏情况下调用相册崩溃的问题
- ios8 下iPad调用相册的方法!
- 进入相册选取图片和拍照方法 和解决在横屏状态下的调试
- iPad横屏调用相册,出现闪退
- 【iOS开发】iPad横屏打开系统相册崩溃,解决方案
- 解决横屏时调用系统相册崩溃的问题
- weblogic下使用hibernate3的异常问题及解决
- 在iPad iOS8环境下打开相册或者拍照
- 解决iOS8下ALAssetsLibrary创建相册的bug
- iOS10适配 完美解决相机、相册等权限的使用
- iOS8的iPad环境下打不开相册或者拍照
- 不同框架下相册及相机的使用权限
- Vbox异常解决-centos下的安装
- ALAsset 相册的使用
- 照相机 相册 以及相册的使用
- 百度地图使用的异常解决
- 苹果IPAD的使用心得
- IOS9 HTTP 不能正常使用的解决办法
- CXF开发webservice的小demo以及需要的jar包
- maven依赖关系中Scope的作用
- python第一章-字符串
- google guava
- IPAD下使用相册横屏异常的解决
- java实现链表和栈
- Qt使用教程之创建一个基于Qt部件的应用程序(二)
- Shell 同时读取多个文件
- android volley(三)使用Volley加载网络图片
- MPLAB X IDE使用心得
- try-catch-finally学习
- android Application类的详细介绍
- activity属性设置大全