开发者

Why my presentModalViewController method doesn't work

开发者 https://www.devze.com 2023-03-18 00:04 出处:网络
I created a UIImagePickerController in the viewDidLoad method in my rootViewController. - (void)viewDidLoad {

I created a UIImagePickerController in the viewDidLoad method in my rootViewController.

- (void)viewDidLoad {
    [super viewDidLoad];

    UIImagePickerController *pickerController=[[UIImagePickerController alloc] init];
    pickerController.sourceType=UIImagePickerControllerSourceTypeSavedPhotosAlbum;
    pickerController.delegate=self;

    [self presentModalViewController:pickerController animated:YES];
    [pickerController release];
}

But the view of UIImagePickerViewController didn't开发者_开发问答 appear on the screen.

The SDK version is 4.3

Is there some mistakes i make?

Thanks!


viewDidLoad is called after the view has been loaded and before the view is displayed. viewDidAppear: is called when the view is onscreen and is the correct point to present a modal view controller.

And if you want to do it only once, you might want to consider using a BOOL to keep track of it.

0

精彩评论

暂无评论...
验证码 换一张
取 消