Do you have any methods for going from CameraRoll

2020-05-08 00:59发布

I'm trying to go from Camera Roll to a new view controller. So basically I want to be able to choose a picture and after choosing the picture, it will be displayed on an imageView on a new view controller? Is that hard to make ?

-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:
(NSDictionary *)info{
self.chosenImage = info[UIImagePickerControllerOriginalImage];
 [self.imageView setImage:self.chosenImage];
[self dismissViewControllerAnimated:YES completion:nil];
}

-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[self dismissViewControllerAnimated:YES completion:nil];
}

1条回答
地球回转人心会变
2楼-- · 2020-05-08 01:47

in your image picker delegate methods, whenever you take image it goes in following method

-(void)imagePickerController:(UIImagePickerController *)picker
  didFinishPickingImage : (UIImage *)image
             editingInfo:(NSDictionary *)editingInfo
{
 //store image here as NSData or as you like 
 // go to the view controller when you want to use image and use the image data
  // do all the stuf you need in this method
}
查看更多
登录 后发表回答