【问题标题】:ipad camera interface orientationipad相机界面方向
【发布时间】:2014-12-16 01:44:19
【问题描述】:

我想创建 iPad 相机,在此之前我会创建纵向的 iPhone 相机应用程序。

当我从相册(设备相册)中选择照片时,iPad 应用程序抛出错误:

Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [PUUIAlbumListViewController shouldAutorotate] is returning YES'

这是我从相册中选择照片的代码:

UIImagePickerController *pickerController = [[UIImagePickerController alloc] init];
pickerController.delegate = self;
pickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
pickerController.mediaTypes = @[(NSString *) kUTTypeImage];
pickerController.allowsEditing = NO;
[self presentViewController:pickerController animated:YES completion:nil];

我必须添加什么才能从 iPad 横向访问它?

【问题讨论】:

  • 你想只使用纵向吗?你想在你的应用中支持什么方向
  • 我的 iphone 版本显示为 potrait UI,这没问题。我的 ipad 版本显示为横向 UI,以前在尝试从需要纵向定位的设备相册中获取照片时出现问题。

标签: ios objective-c ipad


【解决方案1】:

我找到了解决方案,案件已结案。 我添加了我的 appdelegate.m:

-(NSUInteger)application:(UIApplication *)application 
    supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        return UIInterfaceOrientationMaskAll;
    else  /* iphone */
        return UIInterfaceOrientationMaskAllButUpsideDown;
}

【讨论】:

  • 好!但请注意,您可以按照我所说的方式完成相同的操作 - 通过编辑 Info.plist。它有一组适用于 iPad 的设置和一组适用于 iPhone 的设置。因此,您可以完全不使用任何代码,只需在目标编辑器中选中正确的复选框,如我的屏幕截图所示。不过,你的做法并没有错。
  • 如果我编辑 info.plist 成为所有设备方向,我的 ipad 应用程序变得不受控制,因为我使用横向 UI 创建我的应用程序。所以当用户调用 xib 和情节提要时,横向将显示。但在某些情况下,例如从需要 potrait 方向的设备相册中获取照片,我的 ipad 应用程序会将其显示为 potrait 方向。所以,我不需要在每个视图控制器上更改设备方向。
  • 不听就学不会。它的工作方式完全相同。试试看。
【解决方案2】:

它工作正常,但是当我们启动应用程序时,它会在左侧显示肖像。所以请告诉我们如何限制所有肖像事件。 -(NSUInteger)应用程序:(UIApplication *)应用程序 supportedInterfaceOrientationsForWindow:(UIWindow )window {if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) return UIInterfaceOrientationMaskAll;else / iphone */returnUIInterfaceOrientationMaskAllButUpsideDown; }

【讨论】:

    猜你喜欢
    • 2012-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 2011-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多