8***@qq.com
8***@qq.com
  • 发布:2020-03-31 14:13
  • 更新:2022-10-24 15:20
  • 阅读:1350

uniapp 调用ios原生 UIImagePickerController 代理方法不走

分类:uni-app

var pickerVC = plus.ios.newObject("UIImagePickerController");
var navDelegate = plus.ios.implements("UINavigationControllerDelegate");
var pickerDelegate = plus.ios.implements("UIImagePickerControllerDelegate",{
"imagePickerController:didFinishPickingMediaWithInfo:":function(picker,info){
console.log("111");
console.log(info);
}
});

            plus.ios.invoke(pickerVC,"setPickerDelegate",pickerDelegate);  
            plus.ios.invoke(pickerVC,"setNavDelegate",navDelegate);  

            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:",pickerVC,true,null);
2020-03-31 14:13 负责人:无 分享
已邀请:
dafeizhu

dafeizhu

实例方法挂载监听器,用setAttribute

var pickerVC = plus.ios.newObject("UIImagePickerController");  
var pickerDelegate = plus.ios.implements("UIImagePickerControllerDelegate",{  
    "imagePickerController:didFinishPickingMediaWithInfo:":function(picker,info){  
        console.log("111");  
        console.log(info);  
    }  
});  
pickerVC.plusSetAttribute('delegate', pickerDelegate);

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