我正在创建一个应用程序,这是在景观模式下,我正在使用UIImagePickerController
拍摄照片使用iPhone相机在它,我想创建它在景观模式。
但正如苹果公司的文档所暗示的那样,UIImagePickerController
不支持横向,那么我应该怎么做才能获得所需的功能呢?
发布于 2013-10-28 17:14:50
如果您想在横向模式下使用UIImagePickerController,请使用user1673099's answer,而不是:
- (BOOL)shouldAutorotate
{
return NO;
}
使用:
- (UIInterfaceOrientationMask)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}
然后,选取器将以横向模式打开:
但一定要检查部署信息中的肖像:
发布于 2017-10-27 04:09:06
这是一个支持所有界面方向旋转的版本:
/// Not fully supported by Apple, but works as of iOS 11.
class RotatableUIImagePickerController: UIImagePickerController {
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .all
}
}
这样,如果用户旋转她的设备,它将更新选取器控制器以支持当前方向。只需像平常一样实例化UIImagePickerController即可。
如果只想支持方向的一个子集,可以返回一个不同的值。
发布于 2014-07-28 19:48:09
在横向模式下使用UIImagePickerController
的正确方法是将其放入UIPopoverController
中
- (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];
}
https://stackoverflow.com/questions/19374237
复制相似问题