ios5:在另一个模态视图中启动来自NSObject类的电子邮件

时间:2012-03-24 14:12:28

标签: email ios5 modal-dialog nsobject

我有一个从多个类调用的公共操作表(在NSObject类中)。其中一项行动是启动电子邮件。从加载的第一个NIB调用时,一切都很好用。但是,在我使用模态视图切换NIB之后,电子邮件(它自己的模态视图)将不会出现在任何这些中(但所有其他操作都可以正常工作)。我认为这是因为它们是模态视图而不是App的委托调用的viewController。我假设下面的“rootViewController”是问题。我被卡住了。帮助赞赏。

-(void)SendEmail {


// all this NSObject to send emails
rootViewController = (UIViewController*)[(AppDelegate*)[[UIApplication sharedApplication] delegate] viewController];

// compose
MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
//controller.mailComposeDelegate = self;
controller.mailComposeDelegate = self;


//format message
NSArray *recipientsArray = [[NSArray alloc] initWithObjects:@"support@A___.com", nil];  // email recipients must be in an array
[controller setToRecipients:recipientsArray];
[controller setSubject:[NSString stringWithFormat:@"A question about %@",stuff]];
//[controller setMessageBody:outputMutString isHTML:YES];

//send
if (controller) {
    NSLog(@"email controller");
    [rootViewController presentModalViewController:controller animated:YES];
}

}

0 个答案:

没有答案