2011-07-05 76 views
2

我使用基於視圖的應用程序模板創建了一個項目。關於presentModalViewController的問題

在我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]; 
} 

我實現委託了。

但是當我運行這個項目時,我沒有得到imagePicker視圖。在屏幕上顯示mainViewController的視圖,而不是imagePicker視圖。

我犯了一些錯誤嗎?

謝謝!

回答

4

將代碼放在錯誤的位置viewDidUnload在視圖從內存中卸載時被調用。將您的代碼放入viewDidAppear:(BOOL)animated方法中。