0

デバイス (iPhone/iPod/iPad) が縦向きに保持されている場合、ユーザーがカメラを有効にしたときに、デバイスを横向きに回転させ、横向きで写真を撮ったりビデオを録画したりするようにユーザーに通知するにはどうすればよいですか?

ただし、アプリ (すべての UIViewControllers、UITableViewControllers など) は縦向きモードのみで、横向きモードではありません。

4

2 に答える 2

0

インターフェイスの向きを確認します。

if (UIInterfaceOrientationIsPortrait([UIDevice currentDevice].orientation))
{
  // call methods to take picture
  ....
}
else
{
  // alert the user this device is not landscape mode
  ...
}
于 2012-09-13T08:49:57.730 に答える
0

iOS 6 では自動回転がわずかに変更されましたが、同じアプローチが引き続き機能しています。

サンプルコード:

@implementation UIImagePickerController (noRotation)

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

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

@end
于 2012-11-20T16:47:38.573 に答える