2011-05-25 19 views
1

使用MFMailComposeViewController工作正常时,手机处于UIInterfaceOrientationPortrait,但是如果我不容许自转我得到这样的事情,当用户旋转手机:MFMailComposeViewController空白屏幕当横向开度模式

enter image description here

所以我决定让视图控制器(这也是一个模式的看法),是调用模式视图旋转视图的一部分:

RootAppInfoViewController.h

#import <UIKit/UIKit.h> 


@interface RootAppInfoViewController : UIViewController <UINavigationControllerDelegate>{ 
    UINavigationController *navigationControl; 
} 

@property (nonatomic,retain) IBOutlet UINavigationController *navigationControl; 

//dismisses this modal view 
- (IBAction)selectHome:(id)sender; 

@end 

RootAppInfoViewController.m

// Override to allow orientations other than the default portrait orientation. 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations. 
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 
} 

(具有这种自动旋转允许旋转由方式这整个视图)。但是,这仅仅是一个视图控制器,我想一个表视图,以呈现模态,所以我有这个类,这是通过RootAppInfoViewController.xib引用这使得这种模式视图表格视图:

AppInfoViewController.h

#import <UIKit/UIKit.h> 
#import <MessageUI/MessageUI.h> 


@interface AppInfoViewController : UITableViewController <MFMailComposeViewControllerDelegate, UINavigationControllerDelegate> { 
    NSMutableArray *dataSourceArray; 
} 

@property(nonatomic, retain) NSMutableArray *dataSourceArray; 

@end 

AppInfoViewController.m

//.. 
/* //NOTE: Commenting or uncommenting this block of code has no effect! 
// Override to allow orientations other than the default portrait orientation. 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations. 
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 
}//*/ 
//... 
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    [tableView deselectRowAtIndexPath:indexPath animated:YES]; 
    NSString *source = [[[self.dataSourceArray objectAtIndex:indexPath.section] objectForKey:kSourceKey] objectAtIndex:indexPath.row]; 

    if(indexPath.section == kFeedbackSection) { 
     if([MFMailComposeViewController canSendMail]) { 
      // fill out email 
      //... 
      MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init]; 
      //MailCompose *controller = [[MailCompose alloc] init]; 
      controller.mailComposeDelegate = self; 
      [[controller navigationBar] setTintColor:[UIColor oceanColor]]; 
      [controller setToRecipients:[NSArray arrayWithObject:kFeedbackEmail]]; 
      [controller setSubject:emailSubject]; 
      [controller setMessageBody:emailBodyTemplate isHTML:NO]; 
      [self presentModalViewController:controller animated:YES]; 
      [controller release]; 
     } else { 
      [UIAlertHelper mailErrorAlert]; 
     } 
    } //... 

} 

#pragma mark - 
#pragma mark MFMailComposeViewControllerDelegate methods 

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { 
    [self dismissModalViewControllerAnimated:YES]; 
} 

评论或不注释掉这一类的自转代码没有任何影响。保持设备直立并点击加载MFMailComposeViewControlleryeilds的行没有问题,它加载直立,然后它旋转得很好。然而,加载表视图,保持它侧身,然后轻敲与MFMailComposeViewController行加载模态视图控制器作为一个空白屏幕:

enter image description here

发生这种情况无论是在模拟器和实际的物理设备。

任何人都知道这是怎么回事?提前致谢!

+0

你是否设法解决这个问题呢?我发现很相似的问题。 – sarunw 2012-03-09 15:16:55

+0

我是通过向苹果发送技术服务事件做到的。我会很快发布修复。感谢您的提醒。 – Stunner 2012-03-09 19:59:33

+0

@Stunner什么是修复? – 2013-05-24 14:41:38

回答

0

为了充分解释答案,我必须先详细说明我的模态视图是如何创建的。

这里是我的观点概述:

RootViewController -> AppInfoViewController -> MFMailComposeViewController

我在RootViewController的有以下方法:

- (IBAction)openEmail:(id)sender { 
    AppInfoViewController *aivc = [[AppInfoViewController alloc] initWithNibName:@"AppInfoViewController" bundle:nil]; 
    aivc.title = @"Email"; 
    [self presentModalViewController:aivc animated:YES]; 
    [aivc release]; 
} 

这将弹出一个模式视图控制器显示从表视图用户将能够深入其他视图。这里的问题是,我创建了模态控制器不将其首先介绍了视图到导航控制器,就像这样:

- (IBAction)openEmail:(id)sender { 
    AppInfoViewController *aivc = [[AppInfoViewController alloc] initWithNibName:@"AppInfoViewController" bundle:nil]; 
    myNavigationController = [[UINavigationController alloc] initWithRootViewController:aivc]; 
    aivc.title = @"Email"; 
    [self presentModalViewController:myNavigationController animated:YES]; 
    [myNavigationController release]; 
    [aivc release]; 
} 

改变我的代码上面后,一切正常。问题不在AppInfoViewController中。