IOS 在Ipad 横屏 上使用UIImagePickerController
2015-03-31 16:36
381 查看
转载前请注明来源:http://www.cnblogs.com/niit-soft-518/p/4381328.html
最近在写一个ipad的项目,该项目必须是横屏。进入正题,有一项功能是要调用系统的牌照和相册,于是本屌用了 UIImagePickerController,兴冲冲的运行了一下,呵呵,崩掉了,然后带着高逼格去查苹果文档,一堆英文,不懂,好吧,百度一下,发现好多同道中人说 UIImagePickerController必须要竖屏,不能横屏~这让我差点泪崩,又继续看苹果文档,发现了新大陆:
Present the user interface. On iPhone or iPod touch, do this modally (full-screen) by calling the
On iPad, the correct way to present an image picker depends on its source type, as summarized in this table:
The table indicates that on iPad, if you specify a source type of
On iPad, if you specify a source type of
好吧,以我四级未过的英语水平就不做翻译了,大概的意思就是说 如果在ipad中用uiimagepickercontroller,必须使用POPOverController,然后我就试着写了一下,果然很OK!
以下是代码:
一个调用相册的功能:
效果:
最近在写一个ipad的项目,该项目必须是横屏。进入正题,有一项功能是要调用系统的牌照和相册,于是本屌用了 UIImagePickerController,兴冲冲的运行了一下,呵呵,崩掉了,然后带着高逼格去查苹果文档,一堆英文,不懂,好吧,百度一下,发现好多同道中人说 UIImagePickerController必须要竖屏,不能横屏~这让我差点泪崩,又继续看苹果文档,发现了新大陆:
Present the user interface. On iPhone or iPod touch, do this modally (full-screen) by calling the
presentViewController:animated:completion:method of the currently active view controller, passing your configured image picker controller as the new view controller.
On iPad, the correct way to present an image picker depends on its source type, as summarized in this table:
Camera | Photo Library | Saved Photos Album |
---|---|---|
Use full screen | Must use a popover | Must use a popover |
UIImagePickerControllerSourceTypePhotoLibraryor
UIImagePickerControllerSourceTypeSavedPhotosAlbum, you must present the image picker using a popover controller, as described in Presenting and Dismissing the Popover. If you attempt to present an image picker modally (full-screen) for choosing among saved pictures and movies, the system raises an exception.
On iPad, if you specify a source type of
UIImagePickerControllerSourceTypeCamera, you can present the image picker modally (full-screen) or by using a popover. However, Apple recommends that you present the camera interface only full-screen.
好吧,以我四级未过的英语水平就不做翻译了,大概的意思就是说 如果在ipad中用uiimagepickercontroller,必须使用POPOverController,然后我就试着写了一下,果然很OK!
以下是代码:
一个调用相册的功能:
/* 相册 */ -(void)Photo:(UIButton *)sender{ imagePicker = [[UIImagePickerController alloc] init]; imagePicker.delegate = self; imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; // 编辑模式 imagePicker.allowsEditing=NO; UIPopoverController *pop=[[UIPopoverController alloc]initWithContentViewController:imagePicker]; // [self presentViewController:imagePicker animated:YES completion:NULL]; [pop presentPopoverFromRect:sender.bounds inView:sender permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES]; }
效果:
![](http://images.cnitblog.com/blog2015/583948/201503/311633214048025.png)
相关文章推荐
- iOS使用UIImagePickerController
- ios中UIImagePickerController 图片选取器的使用
- IOS 摄像头使用(1)-UIImagePickerController
- Monotouch在IPAD与IPhone使用UIImagePickerController的图片选择不同的代码
- ios 使用UIImagePickerController 打开图片库和相机选择图片修改头像(iphone版本)
- IOS 摄像头使用 之UIImagePickerController
- ios 使用UIImagePickerController 打开图片库和相机选择图片修改头像(iphone版本)
- IOS 摄像头使用(1)-UIImagePickerController
- iOS使用照片選取器(UIImagePickerControllerDelegate)後儲存至資料庫、圖片壓縮
- Qt for iOS:使用UIImagePickerController获取一个系统相册中的图片
- iOS开发-使用UIImagePickerController遇到的问题
- ios 使用UIImagePickerController 打开图片库和相机选择图片修改头像
- IOS 学习--- UIImagePickerController的使用
- iOS 横屏中添加UIImagePickerController获取系统图片
- iOS 使用UIImagePickerController
- iOS之摄像头的使用-----UIImagePickerController
- IOS6 UIImagePickerController在IPAD横屏闪退解决办法
- iOS在更改用户头像并保存至本地沙盒目录中对于UIImagePickerController、UIAlertController的使用
- IOS开发之小实例--使用UIImagePickerController创建一个简单的相机应用程序
- iOS使用UIImagePickerController调用系统相机、相册与图库