Solskjaer
Solskjaer

Reputation: 175

Why my presentModalViewController method doesn't work

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!

Upvotes: 1

Views: 610

Answers (1)

Deepak Danduprolu
Deepak Danduprolu

Reputation: 44633

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.

Upvotes: 4

Related Questions