2009-10-27 37 views
0

我一直在這裏打了我幾個小時的頭。我有一些示例代碼(使用UINavigationController),當視圖加載相機膠捲時將出現。但是,當我嘗試將相同的代碼合併到具有tabBarController的應用程序中時,我得到一個空白模式UIImagePickerController。我沒有找到我做錯了什麼。如何用TabBarController實現一個UIImagePickerController

// bring up image picker 
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeSavedPhotosAlbum]) { 

    NSLog(@"UIImagePickerControllerSourceTypePhotoLibrary available"); 

    UIImagePickerController *ipc = [[UIImagePickerController alloc] init]; 
    ipc.delegate  = self; 
    ipc.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; 
    ipc.allowsEditing = YES; 

    [self.tabBarController presentModalViewController:ipc animated:YES]; 
    [ipc release]; 
} 

任何洞察力將不勝感激。

+0

難道你的樣品在'viewDidLoad'這個代碼?它是否在其導航控制器或自身上調用了「presentModalViewController:animated:'? (並且您知道示例代碼有效?) – 2009-10-27 06:05:46

+0

根控制器將調用presentModalViewController:animated:以及模態視圖的viewDidLoad方法具有上述邏輯時。 – 2009-10-30 19:32:48

回答

0

不知道發生了什麼變化,但可以通過從tabBarController中調用presentViewController來實現。這是現在的標準,並確保您的相機或圖像選擇器始終呈現爲全屏模式視圖。

參考:presentViewController

相關問題