加載我的視圖時,我似乎無法啓動相機。我最終使用戶必須找到並按下屏幕上的按鈕才能加載攝像機(冗餘)。我怎樣才能做到這一點?碼如下:如何在viewDidLoad上啓動iPhone相機?
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
self.imgPicker = [[UIImagePickerController alloc] init];
self.imgPicker.allowsImageEditing = NO;
self.imgPicker.delegate = self;
self.imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[super viewDidLoad];
[self presentModalViewController:self.imgPicker animated:YES];
}
UPDATE:
放置上述代碼到-viewDidAppear:(BOOL)動畫允許發射攝像機,但應用程序與最後例程被[UIWindowController transitionViewDidComplete應聲隨即: fromView:toView]; (如調試器引用)
謝謝凱夫拉爾!你從潛在的頭痛中解救了我。 – RexOnRoids 2009-08-31 05:19:58
更新: - (void)viewDidAppear:(布爾)動畫在這種情況下工作。謝謝! – RexOnRoids 2009-08-31 05:21:16
更新-2:相機顯示,但我的應用程序退出:「錯誤EXC_BAD_ACCESS」 – RexOnRoids 2009-08-31 05:26:42