gpt4 book ai didi

objective-c - UIActivityViewController 关闭 MailViewController

转载 作者:太空狗 更新时间:2023-10-30 03:35:50 25 4
gpt4 key购买 nike

我已尝试通过 UIActivityViewController 发送电子邮件,它工作正常,但邮件 View 在发送电子邮件后并未关闭。当用户按下取消按钮时,它也不会关闭。

我该怎么做才能解决这个问题?

这里是我用过的代码:

//conf share view
NSString *textToShare = @"Teststring!";
UIImage *imageToShare = fetchedImage;
NSURL *urlToShare = [NSURL URLWithString:string_url];
NSArray *activityItems = [[NSArray alloc] initWithObjects:textToShare, imageToShare,urlToShare,nil];

UIActivity *activity = [[UIActivity alloc] init];

NSArray *applicationActivities = [[NSArray alloc] initWithObjects:activity, nil];
UIActivityViewController *activityVC =
[[UIActivityViewController alloc] initWithActivityItems:activityItems
applicationActivities:applicationActivities];

activityVC.excludedActivityTypes = @[UIActivityTypeAssignToContact,
UIActivityTypePostToWeibo,
UIActivityTypeCopyToPasteboard,
UIActivityTypeSaveToCameraRoll,
UIActivityTypePrint];

[activityVC setCompletionHandler:^(NSString *activityType, BOOL completed) {
NSLog(@"CompletionHandler was called!");
}];

谢谢!

最佳答案

我有解决方案。你想在你的基础上展示 UIActivityViewController ,即你的最高或最后一个 View Controller 。就我而言,这有效:

[[[self parentViewController] parentViewController] presentViewController:activityViewController animated:YES completion:nil];

自己尝试调用 parentViewController 多少次,直到您访问最高层的 View Controller 。在我的简单 MasterView/DetailView 应用程序中,我不得不调用它两次。

关于objective-c - UIActivityViewController 关闭 MailViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12882198/

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