我一直在寻找一个答案,但无法拿出任何东西。显然,iPhone SDK 3.0使得它可能的UIImagePickerController可以显示在横向模式 - 但我没有找到,将允许该任何方法。我认为,如果应用程序是在景观默认情况下它会自动调整图像控制器,但不是为我工作。

感谢您的帮助!

有帮助吗?

解决方案

我没有检查这是否是非法的,但它为我工作。 如果你想的UIImagePickerController开始(并保持)在横向方向代码:

//Initialize picker

UIImagePickerController * picker = [[UIImagePickerController alloc] init];
   picker.delegate = self;


//set Device to Landscape. This will give you a warning. I ignored it.
//warning: 'UIDevice' may not respond to '-setOrientation:'


[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];

//Set Notifications so that when user rotates phone, the orientation is reset to landscape.
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

//Refer to the method didRotate:   
[[NSNotificationCenter defaultCenter] addObserver:self
              selector:@selector(didRotate:)
               name:@"UIDeviceOrientationDidChangeNotification" object:nil];

//Set the picker source as the camera   
picker.sourceType = UIImagePickerControllerSourceTypeCamera;

//Bring in the picker view   
[self presentModalViewController:picker animated:YES];

的方法didRotate:

- (void) didRotate:(NSNotification *)notification

{
      //Maintain the camera in Landscape orientation
 [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];

}

其他提示

没有需要继承;简单地重写modalPresentationStyle属性。

    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.modalPresentationStyle = UIModalPresentationFormSheet;
    [viewController presentViewController:picker animated:YES completion:NULL];

如果你只需要摆脱警告试试

@interface UIDevice ()
    -(void)setOrientation:(UIDeviceOrientation)orientation;
@end

我已经开发了横向模式UIImagePicker类。伟大工程,我开发的应用程序:希望它为你工作太:

的GitHub: https://github.com/imaginaryunit/iOSLandscapeThreadedImagePicker.git

我使用的UIImagePickerController太全景观应用程序。请注意,如果你在风景模式下调用的UIImagePickerController,您的应用程序可以通过苹果的审核小组被拒绝。

我设计了一个简单的工作解决此问题,这使得使用shouldAutoRotate委托。苹果批准用于全景观应用此方法。

请参阅此处细节和可下载的完整项目的源代码。

的UINavigationController 的类别和添加此方法

- (BOOL)shouldAutorotate
{
    return NO;
}

子类UIImagePickerController和倍率modalPresentationStyle如下:

- (UIModalPresentationStyle)modalPresentationStyle
{
    if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
    {
        return UIModalPresentationFormSheet;
    }

    return [super modalPresentationStyle];
}

在图像拾取器现在不再形状片在全屏模式下,但它在横向模式看起来不错。 这应该是完全应用商店安全的。

这适用于画廊,不拍照。

我解决了这个问题,如下所示:在取向每次改变之后,我简单的重新创建选择器。尝试这个。不同太歪...

我正在开发的是尽最大的在横向模式下工作的一类。 检查它在GitHub: RACameraController

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top