Im trying to set up an imagePicker
in a new iOS7 Xcode project using storyboards but can't seem to find any examples online until I found the following code.
I've set it up so that when a button is pressed it uses a modal push thing to navigate to the view which has the class of "UIImagePickerController"
which apparently calls in the image picker code.
However when the app is run it won't load anything up after clicking on allow the application to access your photos any chance of some help please?
Error screen shot grab: https://pbs.twimg.com/media/Bdy7v9JCAAABpvS.jpg:large
interface setup:
@interface ridecount_AddRide_ViewController : UIViewController<UIImagePickerControllerDelegate, UINavigationControllerDelegate>{
code:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
UIImagePickerController *controller = [segue destinationViewController];
controller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
controller.delegate = self;
}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
[self dismissViewControllerAnimated:YES completion:nil];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
[self dismissViewControllerAnimated:YES completion:nil];
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
[[self.view viewWithTag:100023] removeFromSuperview];
UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(320/2-200/2, 10, 100, 100)];
imageView.tag = 100023;
imageView.contentMode = UIViewContentModeScaleAspectFit;
imageView.image = image;
[self.view addSubview:imageView];
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…