gpt4 book ai didi

iphone - 如何在 Landscape 而不是 Portrait 中显示 UIImagePickerControllerSourceTypeCamera

转载 作者:行者123 更新时间:2023-11-28 20:22:01 25 4
gpt4 key购买 nike

我正在开发 iPad 应用程序,当我们单击右侧栏按钮时,我会执行如下操作:

    -(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 中的 Orientation 我使用下面的方法,但是我没有写任何与 UIImagePickerControllerSourceTypeCamera 相关的东西

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

}

-(NSUInteger)supportedInterfaceOrientations
{

return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationPortrait;
}

最佳答案

你不应该这样做。苹果文档摘录:

Important: The UIImagePickerController class supports portrait mode only. This class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified, with one exception. You can assign a custom view to the cameraOverlayView property and use that view to present additional information or manage the interactions between the camera interface and your code.

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

关于iphone - 如何在 Landscape 而不是 Portrait 中显示 UIImagePickerControllerSourceTypeCamera,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15521614/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com