元玉
元玉
  • 发布:2016-05-25 19:20
  • 更新:2019-12-27 09:38
  • 阅读:2798

【报Bug】在iOS的native.js中implements实现代理方法的时候,监听只能返回一个参数

分类:Native.js

详细问题描述
[内容]
在使用njs的时候(iOS)监听了
var delegate = plus.ios.implements('UIImagePickerControllerDelegate',
{'imagePickerController:didFinishPickingMediaWithInfo:':function(picker,info){
console.log('info:'+arguments.length);
plus.ios.invoke(arguments[0],'dismissViewControllerAnimated:completion:','YES',null);
}});
打印的参数长度为1,但是url在第二个参数中。选取相册的时候有三个参数,打印的结果还是只有一个参数。

重现步骤
[步骤]
[结果]想获取文件路径,oc如下

  • (void)imagePickerController:(UIImagePickerController )picker didFinishPickingMediaWithInfo:(NSDictionary )info
    {
    ALAssetsLibrary library = [[ALAssetsLibrary alloc] init];
    NSURL
    recordedVideoURL= [info objectForKey:UIImagePickerControllerMediaURL];
    if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:recordedVideoURL]) {
    [library writeVideoAtPathToSavedPhotosAlbum:recordedVideoURL
    completionBlock:^(NSURL assetURL, NSError error){}
    ];
    }

    [picker dismissViewControllerAnimated:YES completion:nil];
    }
    [期望] 期望能拿到第二个参数(info),从而获取文件路径

运行环境
[系统版本] mac OS 10.11.5
[浏览器版本]
[IDE版本] HBuilder 7.1.2.201605102311
[mui版本] HBuilder 7.1.2.201605102311

附件
[代码片段]
function fromCameraVedioIOS(){
var cameraVideo = plus.ios.newObject("UIImagePickerController");
plus.ios.importClass('NSDictionary');
var delegate = plus.ios.implements('UIImagePickerControllerDelegate',
{'imagePickerController:didFinishPickingMediaWithInfo:':function(picker){
console.log('info:'+arguments.length);
plus.ios.invoke(arguments[0],'dismissViewControllerAnimated:completion:','YES',null);
}});
cameraVideo.plusSetAttribute('delegate',delegate);
cameraVideo.plusSetAttribute('sourceType',1);
var iosArray = plus.ios.newObject('NSMutableArray');
plus.ios.invoke(iosArray,'addObject:','public.movie');
cameraVideo.plusSetAttribute('mediaTypes',iosArray);
cameraVideo.plusSetAttribute('videoMaximumDuration',10.000000000000001);
console.log('du:'+cameraVideo.plusGetAttribute('videoMaximumDuration'));
var UIApplicationClass = plus.ios.importClass("UIApplication");
var UIAppObj = UIApplicationClass.sharedApplication();
var del = plus.ios.invoke(UIAppObj,"delegate");
// console.log(JSON.stringify(del));
var appWindowObj = plus.ios.invoke(del,"window");
var appRootController = plus.ios.invoke(appWindowObj,"rootViewController");
plus.ios.invoke(appRootController,"presentViewController:animated:completion:",cameraVideo,"YES",null);

        }  

[安装包]真机

2016-05-25 19:20 1 条评论 负责人:无 分享
已邀请:
跑神的心

跑神的心

遇到了两个问题
1,设置访问相机,拍照模式,但是打开默认选择相册

2,选取照片后,代理不回掉,程序闪退

求告知

  • 8***@qq.com

    请问你程序闪退的问题决绝了吗

    2018-02-24 15:48

  • 首席劝退师

    你获取到视频路径没

    2018-08-24 15:23

你的城主大人

你的城主大人

请问这个解决了么,有没有大神写个例子,我的这样写,点使用照片后会闪退,而且,调用takePicture也会闪退

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