嗨我有一个工作的UIImage选择器控制器,突然它现在只在第二次选择USE时在视图上显示照片。
这是代码
头
@interface UpdatePriceView : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate, UITableViewDelegate, UITextFieldDelegate, CLLocationManagerDelegate > {
UIImagePickerController *myPhoto;
}
@property (nonatomic,retain) UIImagePickerController *myPhoto;
实施
- (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"];
NSLog (@"Image = %@",image);
[self.PhotoView setImage:image];
[self dismissModalViewControllerAnimated:YES];
}
我做错了什么
答案 0 :(得分:1)
尝试这样做:
- (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;
}