デバイス (iPhone/iPod/iPad) が縦向きに保持されている場合、ユーザーがカメラを有効にしたときに、デバイスを横向きに回転させ、横向きで写真を撮ったりビデオを録画したりするようにユーザーに通知するにはどうすればよいですか?
ただし、アプリ (すべての UIViewControllers、UITableViewControllers など) は縦向きモードのみで、横向きモードではありません。
デバイス (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