Uiimagepickercontroller (Get photo album, open camera)

Source: Internet
Author: User

The use of Uiimagepickercontroller must be in the controller, because the need to eject the director, if not in the controller, you can find the controller through the responder chain, or through the proxy method callback

This article looks at address Http://write.blog.csdn.net/postedit


-(ibaction) pickphotolibrary: (ID) Sender {

if (_imagepicker = =Nil) {

_imagepicker = [[uiimagepickercontrolleralloc] init];

}

_imagepicker. Delegate = Self ;

_imagepicker. sourcetype = Uiimagepickercontrollersourcetypesavedphotosalbum;

[self presentviewcontroller:_imagepickeranimated: YEScompletion:nil];

}


-(ibaction) Pickphotocamera: (ID) Sender {

if ([uiimagepickercontrollerissourcetypeavailable: Uiimagepickercontrollersourcetypecamera]) {

if (_imagepicker = =Nil) {

_imagepicker = [[uiimagepickercontrolleralloc] init< /c6>];

}

_imagepicker. delegate =self;

_imagepicker. sourcetype = Uiimagepickercontrollersourcetypecamera;

[self presentviewcontroller:_imagepickeranimated: YEScompletion:nil];

}Else {

NSLog (@ " camera is not available.) ");

}

}



-(void) Imagepickercontrollerdidcancel: (uiimagepickercontroller *) Picker {

_imagepicker. Delegate = Nil ;

[self dismissviewcontrolleranimated:YEScompletion: nil];

}


-(void) Imagepickercontroller: (uiimagepickercontroller *) picker

Didfinishpickingmediawithinfo: (nsdictionary *) Info {

UIImage *originalimage = (UIImage *) [infoobjectforkey:

Uiimagepickercontrolleroriginalimage];

    /*-----------------------

Uiimagepickercontrollermediatype; the media type specified by the user

Uiimagepickercontrolleroriginalimage; get raw picture data

Uiimagepickercontrollereditedimage; post-editing picture data

Uiimagepickercontrollercroprect; picture data after cropping

Uiimagepickercontrollermediaurl; Video Storage Path

Uiimagepickercontrollerreferenceurl//

Uiimagepickercontrollermediametadata//

*/

Self. ImageView. image = originalimage;

// Set Picture zoom fill

self. ImageView . Contentmode = Uiviewcontentmodescaleaspectfill;

_imagepicker. Delegate = Nil ;

[self dismissviewcontrolleranimated:YEScompletion: nil];

}

Article belongs to personal note, strictly prohibit commercial reprint

Uiimagepickercontroller (Get album pictures, open camera)

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.