IOS development Demo similar to WeChat Avatar upload

Source: Internet
Author: User

IOS development Demo similar to upload Avatar
Code:

Items in tablvew in front of the image Selector

-(Void) tableView :( UITableView *) tableView didSelectRowAtIndexPath :( NSIndexPath *) indexPath {// image selector UIImagePickerController * imgPC = [[UIImagePickerController alloc] init]; // sets the proxy imgPC. delegate = self; // allows you to edit the image imgPC. allowsEditing = YES; if (indexPath. row = 0) {NSLog (@ "select image from mobile album"); // Image Library imgPC. sourceType = require; if ([UIImagePickerController isSourceTypeAvailable: available]) {// display controller [self presentViewController: imgPC animated: YES completion: nil];} else {[SVProgressHUD showInfoWithStatus: @ "please allow the program to open the album"] ;}} else if (indexPath. row = 1) {NSLog (@ ""); // takes an imgPC photo. sourceType = ready; // display controller if ([UIImagePickerController isSourceTypeAvailable: available]) {// display controller [self presentViewController: imgPC animated: YES completion: nil];} else {[SVProgressHUD showInfoWithStatus: @ "please allow the program to run the photo function"] ;}}

After selecting an image, select the image button in the lower right corner of the album or image.

# Pragma-mark proxy after successful Image Selection-(void) imagePickerController :( UIImagePickerController *) picker didFinishPickingMediaWithInfo :( NSDictionary
  
   
*) Info {NSLog (@ "info =%@", info); // obtain the Modified Image UIImage * editedImg = info [UIImagePickerControllerEditedImage]; self. iconView. image = editedImg; [self dismissViewControllerAnimated: YES completion: nil];}
  

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.