[英]how to capture avfoundation in landscape mode instead of portrait mode
[英]How to show UIImagePickerControllerSourceTypeCamera in Landscape instead of Portrait
我正在使用iPad App,當我們單擊右欄按鈕時,我正在執行以下操作:
-(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];
}
我的問題是,當我處於橫向模式時,如果我單擊按鈕。 相機以人像模式顯示(圖像以反向模式顯示)。 但是,如果我搖晃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;
}
你不應該這樣做。 Apple文檔摘錄:
重要提示 :UIImagePickerController類僅支持縱向模式。 該類旨在按原樣使用,不支持子類化。 此類的視圖層次結構是私有的,除了一個例外,不得修改。 您可以將自定義視圖分配給cameraOverlayView屬性,並使用該視圖顯示其他信息或管理攝像頭界面與您的代碼之間的交互。
它在這里: http : //developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.