2012-08-02 19 views
-1

大家好我將設備設置爲橫向模式,在該模式下,按下「照片庫」按鈕時,縱向模式下的圖庫打開,選擇圖片將從畫廊回到風景模式。我想在橫向模式下以橫向模式打開圖庫。雖然iPhone處於橫向模式,但縱向模式下仍然出現光照

我用這個代碼事先而是開照相館

- (void)imagesFromGallery{ 
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
{ 
    if(!popover) 
    { 
     popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker]; 
    } 

    [popover presentPopoverFromRect:CGRectMake(500, 620, 0, 0) 
          inView:self.view 
      permittedArrowDirections:UIPopoverArrowDirectionUp 
          animated:YES]; 
} 
else 
{ 
    [self presentModalViewController:imagePicker animated:YES]; 
} } 

感謝....

+1

照片庫總是以縱向模式打開,您無法將其更改爲橫向模式。但是,如果您獲取所有圖像並製作自己的視圖,則無法進行任何操作。這將是非常乏味的! – 2012-08-02 06:43:20

+0

在發佈這樣的問題之前,請閱讀文檔。 Apple提供所有參考資料是有原因的。搜索文檔所花費的時間要少於發佈此問題的時間。 [引用文檔](http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html)「重要UIImagePickerController類只支持縱向模式。」 – 2012-08-02 08:06:38

回答

2

提出它的

[self presentModalViewController:imagePicker animated:YES]; 

的imagePickerView添加到self.view並設置imagePicker的框架

[self.view addSubview:imagePicker.view]; 

希望它能爲你效勞。

+0

非常感謝iYahoo,對我來說工作得很好.... – srinivas 2012-08-02 10:01:34

0

以上答案正常。但是,一旦你加載圖片庫,滾動視圖並選擇文件夾是一個問題。

子類UIImagepicker是正確的選擇。只需創建一個UIImagepicker的子類並添加下面的方法。

-(NSUInteger)supportedInterfaceOrientations 
{ 

    return UIInterfaceOrientationMaskAll; 
} 

其餘的,asusual alloc this viewcontroller and present。

相關問題