繁体   English   中英

Xcode仅在横向拍摄照片/视频

[英]Xcode taking photo/video only in landscape

如何确保用户激活相机时,如果将设备(iPhone / iPod / iPad)作为肖像握住,我想通知用户将设备旋转到横向并以横向拍摄照片/录制视频?

然而,应用程序(我所有的UIViewControllers,UITableViewControllers等),在人像模式而已,没有景观。

检查接口方向:

if (UIInterfaceOrientationIsPortrait([UIDevice currentDevice].orientation))
{
  // call methods to take picture
  ....
}
else
{
  // alert the user this device is not landscape mode
  ...
}

在iOS 6中,自动旋转略有变化,但是,相同的方法仍然有效。

样例代码:

@implementation UIImagePickerController (noRotation)

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation /* iOS 5 */
{
    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}

- (NSUInteger)supportedInterfaceOrientations /* iOS 6 */
{
    return UIInterfaceOrientationMaskLandscape;
}

@end

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM