gpt4 book ai didi

iphone - 如何从 View 和 View Controller 中删除关联?

转载 作者:搜寻专家 更新时间:2023-10-30 20:20:09 24 4
gpt4 key购买 nike

当我在发送电子邮件后尝试显示 facebook 共享时(使用 MFMailComposeViewController)我收到此错误:

A view can only be associated with at most one view controller at a time! View [EAGLView] is associated with [EmailViewController]. Clear this association before associating this view with [FacebookView].'

[EmailViewController removeFromParentViewController];什么都不做

EmailViewController.view = nil;导致白屏,即使电子邮件表单早已消失。

如何让它忘记我曾经发送过电子邮件并使 View 层次结构恢复到以前的状态?如果我没有发送电子邮件,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];

}
}

最佳答案

已修复。

改变

        self.view = eaglView;

        [eaglView addSubview:self.view];

关于iphone - 如何从 View 和 View Controller 中删除关联?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13812028/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com