gpt4 book ai didi

ios - UIActivityViewController 共享应用列表为空

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:02:44 24 4
gpt4 key购买 nike

我想通过UIActivityViewController分享图片到微信,我的代码如下

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"已为您复制消息内容,请在分享内容框中粘贴!" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
UIActivityViewController *activityViewController =[[UIActivityViewController alloc] initWithActivityItems:array applicationActivities:nil];
activityViewController.excludedActivityTypes = @[UIActivityTypePostToFacebook,UIActivityTypeAirDrop];
[self presentViewController:activityViewController animated:TRUE completion:nil];
}];
[alert addAction:cancel];
[self presentViewController:alert animated:YES completion:nil];

但是共享弹出菜单变空了

enter image description here

哪里错了?

任何帮助将不胜感激!谢谢

编辑:我发现我的数组是空的,因为我在那个数组中添加了错误的图像,图像 url 是错误的。所以我的共享弹出菜单是空的。现在,它解决了!谢谢你们!

最佳答案

我认为这是由于空数组而发生的,因此您需要将填充的数组传递给 ActivityController。

 NSArray * array = @[[NSString stringWithFormat:@"pass your data"], [NSURL URLWithString:@"http://www.google.com"]];// this occur due to this
UIActivityViewController *activityViewController =[[UIActivityViewController alloc] initWithActivityItems:array applicationActivities:nil];
activityViewController.excludedActivityTypes = @[UIActivityTypePostToFacebook,UIActivityTypeAirDrop];
[self presentViewController:activityViewController animated:TRUE completion:nil];

关于ios - UIActivityViewController 共享应用列表为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40759476/

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