2009-07-09 6 views
5

私のアプリはランドスケープベースです。私はランドスケープでMFMailComposeViewControllerを使用したいと思いますが、オリエンテーションに関してnotifiyするものは何も見つかりません。ランドスケープでは、MFMailComposeViewControllerは、メール作成ウィンドウの上部のみを表示し、横から見ると、左側から来ます。基本的には、風景画面の半分をカバーしています。メール作成ウィンドウをポートレートではなく横長で表示する方法はありますか?MFMailComposeViewControllerをランドスケープで表示

--- EDIT --- 私はメール作成をロードしたいビューを次のように導出される。以上のことから

//from first UIViewController 
[self presentModalViewController:secondView animated:YES]; 

//from secondView (a UIViewController), I load the info view, which is where the mail compose shows 
InfoController *infoController = [[InfoController alloc] initWithNibName:@"Info" bundle:[NSBundle mainBundle]]; 
[self.view addSubview:infoController.view]; 

、メール作成親ビューがロードされた三番目です。 Info.plistファイルでは、私はこれを実行します。

UIInterfaceOrientation = UIInterfaceOrientationLandscapeRight 

答えて

6

ネストされたUIViewControllerにMailViewControllerを表示する場合は、メインのUIViewControllerに表示してみてください。これは私の問題を解決しました。私はちょうど私のメインコントローラをメインコントローラに渡しました。

+1

私のために働いた!ありがとう! 私も理由を理解しました。メインビューコントローラは私たちの場合はローテーションを処理し、それを変更するのはUIInterfaceRotationだけです。メールコンポーザーはviewcontrollerの回転に従って自分自身を提示します – tadejsv

+0

@Dimitris、私にサンプルを送ってください – Ravi

+0

@Ravan私はそれを見つけられないと思っていません。また、5年前のコードはiOSの開発に役立つと思います...それ以来、物事が大きく変わったはずです。 – Dimitris

0

私は風景のアプリを持っている、とMFMailComposeViewControllerを示すことは正常に動作するようです...私のアプリが時々あるためUIImagePickerController ポートレートモードに切り替える必要があり

self.bounds = CGRectMake(0, 0, 480, 320); 
self.center = CGPointMake(160, 240); 
self.transform = CGAffineTransformMakeRotation(M_PI/2); 

MFMailComposeViewControllerは、それらの値を拾うと私を表示する方法を知っている必要があります...ランドスケープモードではありません作業を行いますので、私は再設定するには風景モードがアップ私の見解では、次のコードを使用しますtself。

+0

あなたはこのようなものが必要。私はself.view.boundsなどを使用する必要があります。 UIViewControllerのviewDidLoadで何を設定すれば、私は望んでいないポートレートをロードします。メールの作成画面が表示される直前にそれを行うと、OPと同じ結果が得られます。 – 4thSpace

+0

メール作成画面の前にどのようなビューを表示していますか? OSにあなたが風景モードであることを教えてもらったのですか、自分の絵を描いて横にしているだけですか? –

+0

遅れて申し訳ありません。あなたの質問に答えてOPを編集しました。見てください。 – 4thSpace

7

Application Delegateクラスの実装で次のコードを追加して、メールコンポーザビューコントローラによる自動ローテーションを無効にすることができます。

@interface MFMailComposeViewController (AutoRotation) 
// to stop auto rotation 
@end 

@implementation MFMailComposeViewController (AutoRotation) 
// stop auto rotation 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // should support all interface orientations. 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 
@end 
+0

ニース!それは完璧に動作します(唯一のものはIOS 6です - 代わりに-shouldAutorotateと-supportedInterfaceOrientationsの代わりに-shouldAutorotateToInterfaceOrientation :)。ありがとう! – Azpiri

-1

この1つは私の作品...

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // return (YES); 
    return (interfaceOrientation==UIInterfaceOrientationLandscapeRight); 
} 

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) 
    { 
     ...... 
    } 
}  
0

は "presentModalViewController:" を送信するようにしてください(AppDelegate中)、アプリケーションウィンドウのrootViewControllerに。

MFMailComposeViewControllerはrootViewController方向を強制できないため、rootViewControllerのnavigationControllerによってプッシュされたviewControllersの向きを強制することができるので、私にとってはうまくいくと思います。私はのUIViewControllerにMFMailComposeViewControllerのデリゲートを使用してい

[((AppDelegate *)[UIApplication sharedApplication]).window.rootViewController presentViewController:mailVC animated:YES]; 
関連する問題