2012-11-24 29 views
0

我禁用了橫向模式,下面的代碼在我的應用程序中。 :在mailViewController中禁用橫向模式

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 


} 

但是,當郵件視圖顯示它以某種方式顯示,使陸地景觀模式。

代碼的郵件操作的:

if ([MFMailComposeViewController canSendMail]) 
      { 
       MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init]; 
       mailer.mailComposeDelegate = self; 
       [mailer setSubject:@"Subject 1"]; 
       UIImage *myImage = [UIImage imageNamed:@"logo_v22.png"]; 
       NSData *imageData = UIImagePNGRepresentation(myImage); 
       [mailer addAttachmentData:imageData mimeType:@"image/png" fileName:@"mobiletutsImage"]; 
       NSString *emailBody = @"Test "; 
       [mailer setMessageBody:emailBody isHTML:NO]; 

       [self presentModalViewController:mailer animated:YES]; 


      } 

主要問題:如何禁用風景模式中mailView?


其它問題:如何更改按鈕的顏色mailView? (取消按鈕和發送按鈕)

回答

1

你需要做的是子類MFMailViewController並覆蓋它的方向。這裏有一個很好的例子:MFMailComposeViewController in landscape你只需要改變它以適應你想要的方向。

編輯:這主要是因爲視圖控制器在默認情況下啓用該模式,它不會從您的主視圖控制器導出,因此需要繼承它

+0

我使用的IOS 5.1 – ignotusverum

+0

我已經編輯我的答案爲您提供更正確的解決方案。希望有所幫助 – Madivad