我如何确保当用户激活他的相机时,如果设备(iPhone / iPod / iPad)被设为肖像,我想通知用户将设备旋转到横向并拍摄风景照片/录制视频?
但是,app(我所有的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
2 回答
检查界面方向:
在iOS 6中,自动旋转略有变化,但是,相同的方法仍然有效 .
示例代码: