2009-07-09 67 views
5

我的應用程序是基於橫向的。我想在橫向上使用MFMailComposeViewController,但找不到任何關於方向的信息。在橫向上,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上顯示它。這爲我解決了這個問題。我剛把主控制器傳給主控制器。

0

我有一個景觀的應用程序,並呈現出MFMailComposeViewController似乎很好地工作......

我的應用程序切換到肖像模式有時會因爲的UIImagePickerController 確實在橫向模式下不工作,所以我用下面的代碼在我看來,重新設立風景模式...

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

的MFMailComposeViewController應該拿起這些價值觀念,知道如何展示我自行宣佈。

+0

我使用MFMailComposeViewController的委託在一個UIViewController:

你需要這樣的事情。我必須使用self.view.bounds等。如果我在UIViewController的viewDidLoad中設置了它,它將加載我不想要的肖像。如果我在顯示郵件撰寫視圖之前執行此操作,則會得到與OP中相同的結果。 – 4thSpace 2009-07-09 03:18:11

+0

在郵件撰寫視圖之前您展示了什麼樣的視圖?你有沒有告訴操作系統你處於橫向模式,還是你正在做自己的繪圖,只是讓它橫向? – 2009-07-10 15:14:37

+0

對不起。我已經編輯了OP來回應你的問題。請看一看。 – 4thSpace 2009-07-15 15:05:26

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 
-1

這個工作對我來說...

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

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

嘗試發送 「presentModalViewController:」 你的應用程序窗口RootViewController的(在AppDelegate中)。

我認爲這適用於我,因爲MFMailComposeViewController不能強制rootViewController方向,但可以強制rootViewController的navigationController推送的viewControllers的方向。

[((AppDelegate *)[UIApplication sharedApplication]).window.rootViewController presentViewController:mailVC animated:YES];