首页 文章

在iPhone上需要风景照片

提问于
浏览
1

是否有一种简单的方法可以强制iPhone在横向拍摄照片而不允许纵向拍摄?该应用程序将是纵向的,但是当相机启动时,我希望它在风景中并且不允许用户拍摄肖像照片 .

2 回答

  • 1

    我不认为你真的可以做到这一点;您可以尝试在UIWindow上放置一个覆盖图,告诉用户将手机保持在横向模式下 . 如果用户以正确的方式握住手机,则删除视图,反之亦然 .

  • 3

    刚刚找到一种简单的方法(在iOS 6上测试过) . 使用此代码,界面永远不会旋转为纵向,只有横向 . 从而:

    你肯定会有一幅风景画

    界面清楚地向用户显示它只是风景

    示例代码:

    @implementation UIImagePickerController (noRotation)
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation /* iOS 5 */
    {
        return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
    }
    
    - (NSUInteger)supportedInterfaceOrientations /* iOS 6 */
    {
        return UIInterfaceOrientationMaskLandscape;
    }
    
    @end
    

相关问题