首页 > 移动平台 > 详细

IOS 在Ipad 横屏 上使用UIImagePickerController

时间:2015-03-31 17:24:22      阅读:287      评论:0      收藏:0      [点我收藏+]

转载前请注明来源:http://www.cnblogs.com/niit-soft-518/p/4381328.html

最近在写一个ipad的项目,该项目必须是横屏。进入正题,有一项功能是要调用系统的牌照和相册,于是本屌用了 UIImagePickerController,兴冲冲的运行了一下,呵呵,崩掉了,然后带着高逼格去查苹果文档,一堆英文,不懂,好吧,百度一下,发现好多同道中人说 UIImagePickerController必须要竖屏,不能横屏~这让我差点泪崩,又继续看苹果文档,发现了新大陆:

 

  1. 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

    The table indicates that on iPad, if you specify a source type of  UIImagePickerControllerSourceTypePhotoLibrary or 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];
}

 

效果:

 技术分享

 

IOS 在Ipad 横屏 上使用UIImagePickerController

原文:http://www.cnblogs.com/niit-soft-518/p/4381328.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!