maskman
maskman
  • 发布:2022-06-18 16:36
  • 更新:2022-06-18 17:30
  • 阅读:271

njs调用ios原生mediaPicker代理delegate设置后闪退

分类:uni-app

参照w_wh写的<通过Native.js访问iOS原生通讯录界面>后仿造写了个使用NJS在ios调用mediaPicker的例子 能调出系统选择器 但是设置delegate后运行会闪退(不设置的话取不到选择的文件结果) 不知道有没有大佬帮忙看看什么问题

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("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);
2022-06-18 16:36 负责人:无 分享
已邀请:
FullStack

FullStack - 【插件开发】【专治疑难杂症】【ios上架、马甲包、白包、过审、已成功上架过几百个】【多款插件已上架:https://ext.dcloud.net.cn/publisher?id=22130】【非诚勿扰】QQ:543610866

Native.js的delegate本来就有问题,用原生插件吧

该问题目前已经被锁定, 无法添加新回复