当我在发送电子邮件(使用MFMailComposeViewController)后尝试显示Facebook分享时,我收到此错误:
视图最多只能与a处的一个视图控制器关联 时间!视图[EAGLView]与[EmailViewController]相关联。明确 在将此视图与[FacebookView]相关联之前的此关联。'
[EmailViewController removeFromParentViewController];什么都不做
EmailViewController.view = nil;即使电子邮件表格早已消失,也会导致白屏。
如何让它忘记我曾发送过电子邮件并使视图层次结构恢复到以前的状态?如果我没有发送电子邮件,则facebook分享有效。
-(IBAction)ShowEmailForm:(char*)pSubject :(char*)pBody :(char*)pTo
{
Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
if (mailClass != nil)
{
if ([mailClass canSendMail])
{
self.view = eaglView;
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:[NSString stringWithFormat:@"%s", pSubject]];
// Set up recipients
if( pTo != nil )
{
NSArray *toRecipients = [NSArray arrayWithObject:[NSString stringWithFormat:@"%s", pTo]];
[picker setToRecipients:toRecipients];
}
// Fill out the email body text
[picker setMessageBody:[NSString stringWithFormat:@"%s",pBody] isHTML:YES];
[self presentViewController:picker animated:YES completion:^(){}];
[picker release];
}
}
}
// Dismisses the email composition interface when users tap Cancel or Send. Proceeds to update the message field with the result of the operation.
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[self dismissViewControllerAnimated:YES completion:^(){ printf("Email form done dismissing.\n"); }];
printf("Email form dismissed.\n");
[self removeFromParentViewController];
//Email was sent.
if (result == MFMailComposeResultSent)
{
printf("Email Sent!\n");
NSString *pEmail = [self findEmailAddresses:controller.view : 0];
}
}
答案 0 :(得分:2)
修正了它。
更改
self.view = eaglView;
到
[eaglView addSubview:self.view];