[IOS] Photo application

Source: Internet
Author: User

For IOS app development, how does one load the Image in the Image Library to the view? Let's take a look! Operation steps: 1. Create a SingleView project, start the simulator, click the browser on the simulator, drag and drop the local image, then click the image long press, and click saveImage To Go To The image library. 2. Modify ViewControllerViewController. h:

# Import <UIKit/UIKit. h> @ interface DXWViewController: UIViewController <UIImagePickerControllerDelegate, response> @ property (retain, nonatomic) IBOutlet UIImageView * imageView; @ property (retain, nonatomic) IBOutlet UIButton * Button; @ property (retain, nonatomic) UIImage * image;-(IBAction) click :( id) sender; @ end ViewController. m: [plain] view plaincopyprint? # Import "DXWViewController. h "@ interface DXWViewController () @ end @ implementation DXWViewController-(void) viewDidLoad {[super viewDidLoad];}-(void) viewWillAppear :( BOOL) animated {self. imageView. image = self. image;} // load succeeded-(void) imagePickerController :( UIImagePickerController *) picker didFinishPickingMediaWithInfo :( NSDictionary *) info {self. image = [info objectForKey: Encrypted]; [picker dismissViewControllerAnimated: YES completion: nil];} // cancel-(void) Cancel :( UIImagePickerController *) picker {[picker dismissViewControllerAnimated: YES completion: nil];}-(void) dealloc {[_ imageView release]; [_ image release]; [_ Button release]; [super dealloc];} // open the image library to obtain the image-(IBAction) click :( id) sender {if ([UIImagePickerController isSourceTypeAvailable: available]) {UIImagePickerController * picker = [[UIImagePickerController alloc] init]; picker. sourceType = UIImagePickerControllerSourceTypePhotoLibrary; picker. delegate = self; picker. allowsEditing = YES; [self presentViewController: picker animated: 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.