我试图在我的视图控制器之一加载后立即显示 UIImagePickerController。我不想让用户按下按钮,所以我覆盖了 viewDidLoad 方法,如下所示:
- (void)viewDidLoad {
[super viewDidLoad];
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePickerController.allowsImageEditing = YES;
imagePickerController.delegate = self;
[self presentModalViewController:imagePickerController animated:YES];
[imagePickerController release];
}
这会编译并运行,但是当加载视图控制器时,不会显示图像选择器。例如,如果我将它附加到按钮的事件,则此代码可以正常工作。有任何想法吗?
谢谢。