iOS development calls system cameras and albums

Source: Internet
Author: User
<span id="Label3"></p><p>Call system cameras and albums (ipad,iphone)<br>Open Camera: (ipad,iphone)<br>Set the sourcetype as the camera, then determine if the camera is available (ipod), no camera, no sourcetype set as photo gallery<br>Uiimagepickercontrollersourcetype sourcetype = uiimagepickercontrollersourcetypecamera;<br>If (![ Uiimagepickercontroller Issourcetypeavailable:uiimagepickercontrollersourcetypecamera]) {<br>SourceType = uiimagepickercontrollersourcetypephotolibrary;<br>//    }<br>SourceType = uiimagepickercontrollersourcetypecamera; Camera<br>SourceType = uiimagepickercontrollersourcetypephotolibrary; Photo Gallery<br>SourceType = uiimagepickercontrollersourcetypesavedphotosalbum; Saved photos<br>Uiimagepickercontroller *picker = [[uiimagepickercontroller alloc] init];//initialization<br>Picker.delegate = self;<br>Picker.allowsediting = yes;//settings can be edited<br>Picker.sourcetype = sourcetype;<br>[self presentmodalviewcontroller:picker animated:yes];//into The camera interface<br>[picker release];<br><br>Open album: (differentiate pad and iphone) for iphone:<br>Uiimagepickercontroller *pickerimage = [[uiimagepickercontroller alloc] init];<br>If ([uiimagepickercontroller issourcetypeavailable:uiimagepickercontrollersourcetypephotolibrary]) {<br>Pickerimage.sourcetype = uiimagepickercontrollersourcetypephotolibrary;<br>Pickerimage.sourcetype = uiimagepickercontrollersourcetypesavedphotosalbum;<br>Pickerimage.mediatypes = [uiimagepickercontroller availableMediaTypesForSourceType:pickerImage.sourceType];<br> <br>}<br>Pickerimage.delegate = self;<br>pickerimage.allowsediting = NO;<br>[self Presentmodalviewcontroller:pickerimage animated:yes];<br>[pickerimage release];<br><br>Open Album for Ipad:<br>Uiimagepickercontrollersourcetype sourcetype = uiimagepickercontrollersourcetypephotolibrary;<br>SourceType = uiimagepickercontrollersourcetypesavedphotosalbum; Saved photos<br>Uiimagepickercontroller *picker = [[uiimagepickercontroller alloc] init];<br>Picker.delegate = self;<br>Picker.allowsediting = No;//whether to Allow editing<br>Picker.sourcetype = sourcetype;<br>/*<br>If rendered from a navigation button, use:<br>presentPopoverFromBarButtonItem:permittedArrowDirections:animated:;<br>If you want to render from a view, use:<br>PresentPopoverFromRect:inView:permittedArrowDirections:animated:<br> <br>If the device is rotated, the position positioning error needs to be repositioned in the following method of the parent view Controller:<br>Didrotatefrominterfaceorientation: (re-set rect inside this method body)<br>Then call Again:<br>-(void) presentpopoverfromrect: (cgrect) rect inview: (UIView *) View Permittedarrowdirections: ( Uipopoverarrowdirection) arrowdirections animated: (BOOL) Animated<br>*/<br>Uipopovercontroller can only be used on ipad devices, and is used to display temporary content that is always displayed at the front of the current view and disappears automatically when clicked elsewhere in the Interface.<br>Uipopovercontroller *popover = [[uipopovercontroller alloc]initwithcontentviewcontroller:picker];<br>Self.imagepicker = popover;<br>Permittedarrowdirections Setting the arrow direction<br>[self.imagepicker presentpopoverfromrect:cgrectmake (0, 0, +) inView:self.view permittedarrowdirections: Uipopoverarrowdirectionany animated:yes];<br>[picker release];<br>[popover release];<br><br>Click on the picture in the photo album and click Use when the camera is Finished.<br>-(void) imagepickercontroller: (uiimagepickercontroller *) picker didfinishpickingmediawithinfo: (NSDictionary *) Info<br><br>Click Cancel to invoke the method<br>-(void) imagepickercontrollerdidcancel: (uiimagepickercontroller *) Picker<br><br>Note: you need to add @property (nonatomic, retain) uipopovercontroller *imagepicker;</p><p><p>iOS development calls system cameras and albums</p></p></span>
Related Article

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.