質問

私はこの答えを探してきたが、何を考え出すことはできません。どうやら、iPhone SDK 3.0はUIImagePickerControllerは、風景モードで表示することができ、それを可能にした - しかし、私はこれを許可する任意の方法を見つけることではないのです。私は、アプリケーションがデフォルトで風景の中にある場合、それは自動的に画像コントローラを調整すると思うだろうが、それは私のために働いていません。

任意の助けてくれてありがとう!

役に立ちましたか?

解決

私は、これは違法であるかどうかをチェックしていないが、それは私のために働きました。

:あなたはUIImagePickerControllerを開始(および滞在)横向きのコード内にしたい場合
//Initialize picker

UIImagePickerController * picker = [[UIImagePickerController alloc] init];
   picker.delegate = self;


//set Device to Landscape. This will give you a warning. I ignored it.
//warning: 'UIDevice' may not respond to '-setOrientation:'


[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];

//Set Notifications so that when user rotates phone, the orientation is reset to landscape.
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

//Refer to the method didRotate:   
[[NSNotificationCenter defaultCenter] addObserver:self
              selector:@selector(didRotate:)
               name:@"UIDeviceOrientationDidChangeNotification" object:nil];

//Set the picker source as the camera   
picker.sourceType = UIImagePickerControllerSourceTypeCamera;

//Bring in the picker view   
[self presentModalViewController:picker animated:YES];

メソッドdidRotateます:

- (void) didRotate:(NSNotification *)notification

{
      //Maintain the camera in Landscape orientation
 [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];

}

他のヒント

サブクラスする必要はありません。単にmodalPresentationStyleプロパティをオーバーライドします。

    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.modalPresentationStyle = UIModalPresentationFormSheet;
    [viewController presentViewController:picker animated:YES completion:NULL];

あなただけの警告トライを取り除くために必要がある場合は、

@interface UIDevice ()
    -(void)setOrientation:(UIDeviceOrientation)orientation;
@end

私は風景モードでUIImagePickerクラスを開発しました。私が開発したアプリケーションのための素晴らしい作品:それはあまりにもあなたのために働く希望ます:

のGitHub: https://github.com/imaginaryunit/iOSLandscapeThreadedImagePicker.gitする

私もUIImagePickerControllerを使用して、すべての-風景のアプリを持っています。あなたは風景モードでUIImagePickerControllerを呼び出す場合、あなたのアプリがAppleの審査チームによって拒否されることが可能であることに注意してください。

私はshouldAutoRotateデリゲートを使用するよう、この問題の周りの簡単な作業を考案しました。 Appleはすべての-景観アプリのこの方法を承認します。

詳細はこちらこちらを参照してくださいダウンロード可能な完全なプロジェクトのソースコードます。

UINavigationControllerするのカテゴリを作成し、これを追加方法

- (BOOL)shouldAutorotate
{
    return NO;
}

サブクラスUIImagePickerControllerとオーバーライドmodalPresentationStyle次のように:

- (UIModalPresentationStyle)modalPresentationStyle
{
    if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
    {
        return UIModalPresentationFormSheet;
    }

    return [super modalPresentationStyle];
}
イメージピッカーは今、もはやフルスクリーンモードでのフォームシートであるが、それはランドスケープモードで良いように見えます。 これは完全にアプリストアセーフである必要があります。

ギャラリーのためではなく、写真を撮るためにこの作品ます。

次のように

私はこの問題を解決:オリエンテーションの各変化の後、私はシンプルなピッカーを再作成します。これを試して。異なっあまりにも曲がっている...

私は風景モードで動作するように最善をしようとするクラスを開発しています。 GitHubの上でそれをチェックアウト: RACameraControllerする

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top