@w_wh 我仿造写了个使用NJS在ios调用mediaPicker的例子 发现delegate有问题 不知道能否麻烦帮忙看下(uni-app)
var picker = plus.ios.newObject("MPMediaPickerController");
plus.ios.invoke(picker, "initWithMediaTypes:", 0x00ff);
picker.plusSetAttribute("prompt", "请选择需要播放的歌曲")
picker.plusSetAttribute("showsCloudItems", false)
picker.plusSetAttribute("allowsPickingMultipleItems", true)
let delegate = plus.ios.implements("MPMediaPickerControllerDelegate", {
"mediaPicker:didPickMediaItems:": function(mediaPicker, mediaItemCollection){
console.log(mediaPicker, mediaItemCollection);
//plus.ios.deleteObject(mediaPicker);
},
"mediaPickerDidCancel:":function(mediaPicker){
console.log(mediaPicker)
//plus.ios.deleteObject(mediaPicker);
}
});
picker.plusSetAttribute(picker, "delegate", delegate);
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");
plus.ios.invoke(appRootController,"presentViewController:animated:completion:",picker,true,null);
//plus.ios.deleteObject(picker);
通过Native.js访问iOS原生通讯录界面(ContactsUI/AddressBookUI)iOS14以上系统不可用网上有关于Native.js访问Android原生通讯录的案例(可以参考:Android调用系统通讯录控件,native.js实现监听startActivityForResu...