How to make a button open up Photo Library?

Discussion in 'iOS Programming' started by pcs are junk, Jan 30, 2010.

  1. pcs are junk macrumors 65816

    Sep 28, 2009
    hi guys, i am trying to start an awesome photography application, but i need to know how to link a button to open the photo library, so people can choose their picture and edit it. i also would like to know how to make the camera button access the camera. please help me out here, i need to get the basics down before i go into the extremely hard stuff. thanks in advance! oh btw, please dont tell me to learn objective c, because the way i learn things is by people telling me how to do it. like people think that im not learning anything if theyre doing it for me, but i really am because i am starting to understand what the words and symbols mean. so i am learning objective c just by people telling me what to do. thanks!
  2. drf1229 macrumors regular


    Jun 22, 2009
    In that case, try something like this:

    -(IBAction) getPhoto:(id) sender {
    	UIImagePickerController * picker = [[UIImagePickerController alloc] init];
    	picker.delegate = self;
    	if((UIButton *) sender == choosePhotoBtn) {
    		picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
    	} else {
    		picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    	[self presentModalViewController:picker animated:YES];

Share This Page