2011-09-08 58 views
0

我修改我的iPhone應用程序,使其與iOS 3.1.3向後兼容進行全屏轉換。我允許用戶從照片庫中加載圖像。我使用以下代碼提供圖像選擇器:UIImagePicker無法在iOS 3.1.3

UIImagePickerController* content = [[UIImagePickerController alloc] init]; 
content.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
content.delegate = self; 
[self presentModalViewController:content animated:YES]; 
[content release]; 

這適用於ios 4.0+。然而,在iOS 3.1.3,從來沒有出現圖像選擇器,我得到以下警告:

Can't perform full-screen transition. The fromViewController's view must be 
within a view that occupies the full screen. 

的fromViewController在這種情況下是一個導航控制器內的可見視圖控制器。導航控制器被設置在用下面的代碼段中的的appDelegate didFinishLaunchingWithOptions:

MyViewController* root = [[MyViewController alloc] initWithNibName:nil bundle:nil]; 
UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:root]; 
aNavigationController.delegate = self;  
[window addSubview:aNavigationController.view]; 

此前試圖加載圖片選擇器,另一個視圖控制器在導航控制器呈現。因此,在圖像採集器加載時,兩個視圖控制器位於導航堆棧中。

基於另一個交,我已經使用根視圖控制器和導航控制器作爲fromViewController(控制器呈現所述圖像拾取器)嘗試。行爲是一樣的。

我想知道如果這個問題有什麼關係的事實,導航控制器的modalPresentationStyle無法在iOS版3.1.3進行設置。對於iOS 3.2+,我將演示風格設置爲UIModalPresentationFullScreen。我相信這是之前iOS的默認設置。不過,我很懷疑,因爲我收到的警告關注全屏視圖。

誰能提供任何其他建議?我一直無法找到任何蘋果文檔,解決從ios 3.x更改爲UIImagePicker或UINavigationController到4.0。

在此先感謝!

回答

0

當視圖控制器是一個導航控制器內我最常做的是:

imagePicker = [[UIImagePickerController alloc]init]; 
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
imagePicker.delegate = self; 

[self.navigationController presentModalViewController:imagePicker animated:YES]; 

希望工程爲您服務!

+0

沒有運氣。當我從導航控制器,根視圖控制器或可見視圖控制器呈現時,我會得到相同的行爲。 – jenonen

+0

@jenonen你如何呈現視圖控制器「在此之前嘗試加載圖像選擇器,另一個視圖控制器導航控制器呈現」? –

+0

[self.navigationController pushViewController:newViewController animated:YES]; – jenonen