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:
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