0

我的iPad應用程序的工作,有顯示UIImagePickerControllerSourceTypeCamera當我們點擊右邊欄按鈕我給像下面的操作:如何在景觀,而不是Potrait

-(IBAction)camerabuttonAction:(id)sender 
{ 
UIImagePickerController *picker = [[UIImagePickerController alloc] init]; 
    picker.sourceType = UIImagePickerControllerSourceTypeCamera; 
    picker.delegate = self; 

    self.popoverController = [[UIPopoverController alloc] initWithContentViewController:picker]; 
    [self.popoverController presentPopoverFromRect:CGRectMake(50, -250, 500, 300) inView:appDelegate.splitview.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES]; 
} 

我的問題是,當我在如果點擊按鈕,則顯示Land Scape模式。照相機以縱向模式顯示(圖像以反向模式顯示以供查看)。但是,如果我搖動iPad,那麼它顯示在LandScape中。

對於iOS6的方向我使用下面的方法,但我沒有寫有關UIImagePickerControllerSourceTypeCamera

- (void)viewWillLayoutSubviews 
{ 
if([self interfaceOrientation] == UIInterfaceOrientationPortrait||[self interfaceOrientation] ==UIInterfaceOrientationPortraitUpsideDown) 
    { 
} 
    else if ([self interfaceOrientation] == UIInterfaceOrientationLandscapeLeft||[self interfaceOrientation] == UIInterfaceOrientationLandscapeRight) 
    { 
} 

} 

    -(NSUInteger)supportedInterfaceOrientations 
{ 

    return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationPortrait; 
} 

在此先感謝

回答

3

你不應該做的事。從蘋果中提取的文檔:

重要:UIImagePickerController類只支持肖像模式。此類旨在按原樣使用,不支持子類。這個類的視圖層次是私有的,不能修改,只有一個例外。您可以將自定義視圖分配給cameraOverlayView屬性,並使用該視圖呈現附加信息或管理攝像頭界面和代碼之間的交互。

它在這裏:http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html

+0

因此,U是說......我必須使用cameraOverlayView,對不對? – Babul 2013-03-20 11:13:00

+0

但是,如果我將我的ipad肖像旋轉到風景,那麼相機會在LandScape @Vincent Saluzzo – Babul 2013-03-20 11:21:55

+0

@Babul中顯示是的,但這是Apple。如果你想要正確並尊重蘋果的推薦,你必須使用'AVFoundation.framework'來做到這一點。 – 2013-03-20 14:25:38

相關問題