Solskjaer
Solskjaer

Reputation: 175

Question about presentModalViewController

I created a project using the View-Based Application template.

In my mainViewController:

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
    UIImagePickerController *pickerController=[[UIImagePickerController alloc] init];
    pickerController.sourceType=UIImagePickerControllerSourceTypeSavedPhotosAlbum;
    pickerController.delegate=self;

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

I implemented the delegate already.

But when I was running this project, I didn't get the imagePicker View. Instead of the imagePicker View, the view of mainViewController was shown on screen.

Did I make some mistakes?

Thanks!!!

Upvotes: 2

Views: 83

Answers (1)

Rahul Vyas
Rahul Vyas

Reputation: 28750

You have put code in a wrong place viewDidUnload is called when a view unloads from memory. put your code into viewDidAppear:(BOOL)animated method.

Upvotes: 4

Related Questions