UIImage picker controller works only the second time through
Hi I have had a working UIImage picker controller and suddenly it now only shows the photo on the view the second time i select USE.
Here's the code
header
@interface UpdatePriceView : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate, UITableViewDelegate, UITextFieldDelegate, CLLocationManagerDelegate > {
UIImagePickerController *myPhoto;
}
@property (nonatomic,retain) UIImagePickerController *myPhoto;
implementation
- (IBAction)Photo{
self.myPhoto = [[UIImagePickerController alloc] init];
self.myPhoto.sourceType = UIImagePickerControllerSourceTypeCamera;
self.myPhoto.delegate = self;
self.myPhoto.allowsEditing = NO;
self.myPhoto.showsCameraControls = YES;
[self presentModalViewController:self.myPhoto animated:YES];
}
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSLog(@"didFinishPickingMediaWithInfo method");
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
开发者_StackOverflow中文版NSLog (@"Image = %@",image);
[self.PhotoView setImage:image];
[self dismissModalViewControllerAnimated:YES];
}
What am i Doing wrong
Try to do that:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
self.photo = [info objectForKey:UIImagePickerControllerOriginalImage];
[picker dismissModalViewControllerAnimated:NO];
[picker release];
}
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
imgView.image = photo;
}
精彩评论