IOS uses Uiimagepickercontroller on ipad flat screen

Source: Internet
Author: User

Please specify the source before reprint: http://www.cnblogs.com/niit-soft-518/p/4381328.html

Recently in writing an ipad project, the project must be a horizontal screen. To get to the point, there is a function is to call the system's license plate and album, so this cock with the Uiimagepickercontroller, excitedly run a bit, hehe, collapsed, and then with high forcing lattice to check the Apple documents, a bunch of English, do not understand, well, Baidu a bit, found a lot of fellow people say Uiimagepickercontroller must be vertical screen, not horizontal screen ~ This let me almost tears, and continue to look at the Apple document, found the new continent:

  1. Present the user interface. On IPhone or IPod touch, does 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-present an image picker-depends on its-source type, as summarized in this table:

     

    camera

    photo Library

    saved Photos Album

    use full screens

    must use a popover

    Must use a popover

    The table indicates that on IPad, if you specify a source type UIImagePickerControllerSourceTypePhotoLibrary of 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 a image picker modally (full-screen) for choosing among saved pictures and movies, the system R Aises an exception.

    On IPad, if you specify a source type UIImagePickerControllerSourceTypeCamera of, you can present the image Picker modally (Full-screen) or by using a Popov Er. However, Apple recommends that's present the camera interface only Full-screen.

Well, in my four level has not been the English level does not do the translation, probably means that if in the ipad with Uiimagepickercontroller, must use the Popovercontroller, then I try to write a bit, really very ok!

Here's the code:

A feature that calls the album:

/*albums*/-(void) Photo: (UIButton *) sender{Imagepicker=[[Uiimagepickercontroller alloc] init]; Imagepicker.Delegate=Self ; Imagepicker.sourcetype=uiimagepickercontrollersourcetypephotolibrary; //edit Modeimagepicker.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];}

Effect:

IOS uses Uiimagepickercontroller on ipad flat screen

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.