【发布时间】:2010-02-17 14:38:06
【问题描述】:
这是我目前的代码:
/* class: myViewController
@interface myViewController: UIViewController
<UIImagePickerControllerDelegate, UINavigationControllerDelegate>
*/
- (IBAction) getPicture {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:picker animated:YES];
}
- (void) imagePickerController:(UIImagePickerController *)thePicker
didFinishPickingMediaWithInfo:(NSDictionary *)imageInfo
{
[[thePicker parentViewController] dismissModalViewControllerAnimated:YES];
UIImage *img = [imageInfo
objectForKey:@"UIImagePickerControllerOriginalImage"];
self.myImageView.image = img;
}
所以基本上我试图从 iPhone 相机中获取照片并将其显示在 UIImageView 中。只要类 myViewController 显示为独立视图,它就可以正常工作。如果我将视图放在 UINavigationController 中,则 UIImageView 在用相机拍摄后不会显示图像。但是,如果我从图书馆中选择一张图片,一切都会好起来的。
那么为什么 UIImageView 不会在 UINavigationController 中显示用相机拍摄的图像呢?
【问题讨论】:
标签: iphone uinavigationcontroller uiimageview camera