首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在横向中使用UIImagePickerController

在横向中使用UIImagePickerController
EN

Stack Overflow用户
提问于 2013-10-15 14:01:01
回答 5查看 31.8K关注 0票数 30

我正在创建一个应用程序,这是在景观模式下,我正在使用UIImagePickerController拍摄照片使用iPhone相机在它,我想创建它在景观模式。

但正如苹果公司的文档所暗示的那样,UIImagePickerController不支持横向,那么我应该怎么做才能获得所需的功能呢?

EN

回答 5

Stack Overflow用户

回答已采纳

发布于 2013-10-28 17:14:50

如果您想在横向模式下使用UIImagePickerController,请使用user1673099's answer,而不是:

代码语言:javascript
复制
- (BOOL)shouldAutorotate
{
    return NO;
}

使用:

代码语言:javascript
复制
- (UIInterfaceOrientationMask)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscape;
}

然后,选取器将以横向模式打开:

但一定要检查部署信息中的肖像:

票数 47
EN

Stack Overflow用户

发布于 2017-10-27 04:09:06

这是一个支持所有界面方向旋转的版本:

代码语言:javascript
复制
/// Not fully supported by Apple, but works as of iOS 11.
class RotatableUIImagePickerController: UIImagePickerController {

  override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
    return .all
  }
}

这样,如果用户旋转她的设备,它将更新选取器控制器以支持当前方向。只需像平常一样实例化UIImagePickerController即可。

如果只想支持方向的一个子集,可以返回一个不同的值。

票数 6
EN

Stack Overflow用户

发布于 2014-07-28 19:48:09

在横向模式下使用UIImagePickerController的正确方法是将其放入UIPopoverController

代码语言:javascript
复制
- (void)showPicker:(id)sender
{
    UIButton *button = (UIButton *)sender;
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.allowsEditing = YES;
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    _popover = [[UIPopoverController alloc] initWithContentViewController:picker];
    [_popover presentPopoverFromRect:button.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19374237

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档