[英]Xcode taking photo/video only in landscape
How do I ensure that when user activates his camera, if the device (iPhone/iPod/iPad) is being hold as portrait, I want to inform user to rotate the device to landscape and take photo/record video in landscape? 如何确保用户激活相机时,如果将设备(iPhone / iPod / iPad)作为肖像握住,我想通知用户将设备旋转到横向并以横向拍摄照片/录制视频?
However, app (all my UIViewControllers, UITableViewControllers, etc) are in portrait mode only, no landscape. 然而,应用程序(我所有的UIViewControllers,UITableViewControllers等),在人像模式而已,没有景观。
Check the interface orientation: 检查接口方向:
if (UIInterfaceOrientationIsPortrait([UIDevice currentDevice].orientation))
{
// call methods to take picture
....
}
else
{
// alert the user this device is not landscape mode
...
}
In iOS 6 autorotation has slightly changed, however, the same approach is still working. 在iOS 6中,自动旋转略有变化,但是,相同的方法仍然有效。
Sample code: 样例代码:
@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.