IOS growth path-call camera and album functions

Source: Internet
Author: User

Open the camera:

// Set sourceType to the camera first, and then determine whether the camera is available (ipod) without a camera. You cannot set sourceType to the Photo Library UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera; // if (! [UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {// sourceType = Hangzhou; // sourceType = Shanghai; // camera // sourceType = Shanghai; // Image Library // sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; // Save the photo UIImagePickerController * picker = [[UIImagePickerController alloc] init]; // initialize picker. delegate = self; picker. allowsEditing = YES; // You can edit picker. sourceType = sourceType; [self presentModalViewController: picker animated: YES]; // enter the camera interface [picker release];

Open album: (differentiate pad and iphone)

For iphone:

UIImagePickerController *pickerImage = [[UIImagePickerController alloc] init];    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {        pickerImage.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;        //pickerImage.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;        pickerImage.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:pickerImage.sourceType];            }    pickerImage.delegate = self;    pickerImage.allowsEditing = NO;    [self presentModalViewController:pickerImage animated:YES];    [pickerImage release];

For ipad:

UIImagePickerControllerSourceType sourceType = Hangzhou; // Save the photo UIImagePickerController * picker = [[UIImagePickerController alloc] init]; picker. delegate = self; picker. allowsEditing = NO; // whether to allow editing picker. sourceType = sourceType;/* If displayed from a navigation button, use: presentpoverfrombarbuttonitem: permittedArrowDi Rections: animated:; if you want to render a view, use: presentpoverfromrect: inView: permittedArrowDirections ctions: animated: if the device is rotated, location error needs to be located again in the following method of the parent View Controller: didRotateFromInterfaceOrientation :( reset rect in this method body) and then call:-(void) presentpoverfromrect :( CGRect) rect inView :( UIView *) view permittedArrowDirections :( UIPopoverArrowDirection) arrowDirections animated :( BOOL) animated * // UIPopoverController can only be used on ipad devices. Temporary content is always displayed at the front of the current view. It disappears automatically when you click somewhere else on the page. UIPopoverController * popover = [[UIPopoverController alloc] initWithContentViewController: picker]; self. imagePicker = popover; // permittedArrowDirections sets the arrow Direction [self. imagePicker presentpoverfromrect: CGRectMake (0, 0,300,300) inView: self. view permittedArrowDirections ctions: UIPopoverArrowDirectionAny animated: YES]; [picker release]; [popopover release];

How to trigger when you click use after the photo camera in the photo album is taken

-(Void) imagepickercontroller :( uiimagepickercontroller *) picker didfinishpickingmediawithinfo :( nsdictionary
*) Info

Click the method called by cancel.

-(Void) imagepickercontrollerdidcancel :( uiimagepickercontroller *) picker

Example: http://download.csdn.net/download/like7xiaoben/4958356

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.