var UIPasteboard = plus.ios.importClass("UIPasteboard");
var generalPasteboard = UIPasteboard.generalPasteboard();
generalPasteboard.plusCallMethod({setValue: msg.title, forPasteboardType: "public.utf8-plain-text"});
// generalPasteboard.plusCallMethod({valueForPasteboardType:"public.utf8-plain-text"});
var NSURL = plus.ios.import('NSURL');
var NSData = plus.ios.import("NSData");
var UIImage = plus.ios.import("UIImage");
var NSArray = plus.ios.import("NSMutableArray");
var activityItems = NSArray.arrayWithCapacity(10);
msg.pictures.forEach(item => {
var imageUrl = NSURL.URLWithString(item)
var data = NSData.dataWithContentsOfURL(imageUrl);
var localImage = UIImage.imageWithData(data);
activityItems.addObject(localImage);
});
var UIActivityViewController = plus.ios.importClass("UIActivityViewController");
var activityVC = new UIActivityViewController();
var activity = plus.ios.invoke(activityVC, "initWithActivityItems:applicationActivities:", activityItems, null);
console.log("activity == ");
console.log(activity);
var UIApplicationClass = plus.ios.importClass("UIApplication");
var UIAppObj = UIApplicationClass.sharedApplication();
var del = plus.ios.invoke(UIAppObj, "delegate");
var appWindowObj = plus.ios.invoke(del, "window");
var appRootController = plus.ios.invoke(appWindowObj, "rootViewController");
console.log("appRootController == ");
console.log(appRootController);
plus.ios.invoke(appRootController, "presentViewController:animated:completion:", activity, "YES", null);
- 发布:2023-03-20 17:03
- 更新:2023-03-21 18:15
- 阅读:366
产品分类: HTML5+
HBuilderX版本号: 3.6.18
手机系统: iOS
手机系统版本号: iOS 16
手机厂商: 苹果
手机机型: iPhone13
打包方式: 云端
示例代码:
操作步骤:
执行代码
执行代码
预期结果:
能弹窗系统分享
能弹窗系统分享
实际结果:
没弹窗也没报错
没弹窗也没报错
bug描述:
IOS UIActivityViewController 不生效
1 个回复
DCloud_IOS_XTY
Native.js运行于独立线程不支持使用UIKit相关API,可以使用uni更先进的插件开发技术UTS插件功能更强大性能更好代码书写更顺手https://uniapp.dcloud.net.cn/plugin/uts-plugin.html