這是我到目前爲止的代碼:iPhone SDK - 如何在UINavigationController中顯示用相機拍攝的照片?
/* 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中顯示用相機拍攝的圖像呢?
我曾經嘗試這樣做沒有任何的運氣。 – dan 2010-02-17 14:47:31
設置圖像後,您是否嘗試過以下方法? [self setNeedsDisplay]; – Shingoo 2010-02-17 14:59:39
不幸的是它並沒有改變任何東西。 – dan 2010-02-17 21:01:49