[]在Native端IOS下提示反射找不到方法?
参考NativePlayer二次开发的文档,实现JS调用OC内class播放视频,(使用最新NativePlayer SDK 0.9.10)报错提示
------------
className = JSProxy
layabox[419:23466] 1 [-1] [1] [JSProxy] [playVideo] [["video/cg.mp4"]]
layabox[419:23284] 2 [-1] [JSProxy] [playVideo] [["video/cg.mp4"]]
layabox[419:23284] reflection error: can not find method signature
layabox[419:23284] Received memory warning.
---TS调用部分代码如下:(调用静态方法,其中Android使用方法调用正常)
if (Laya.Render.isConchApp) {
// 通过反射机制,调用Android和IOS原生代码的类和方法
let className = Laya.Browser.onAndriod ? "com.xxxx.yyyy.JSProxy" : "JSProxy";
console.log("className = " + className);
var jsProxy = Laya.PlatformClass.createClass(className);
jsProxy.call("playVideo", url);
}
---JSProxy.h
#import <Foundation/Foundation.h>
@interface JSProxy : NSObject
+(void)playVideo: (NSString*) url; // 只支持对象类型String类型用NSString
@end
---JSProxy.mm
#import "JSProxy.h"
#import "ViewController.h"
#import <conchRuntime.h>
@implementation JSProxy
+(void)playVideo: (NSString*) url
{
NSLog(@"playVideo");
// 静态函数回调通知JS层
[[conchRuntime GetIOSConchRuntime] runJS: @"video.end()"];
}
@end
请问,代码什么地方有问题,如果修改?谢谢!
------------
className = JSProxy
layabox[419:23466] 1 [-1] [1] [JSProxy] [playVideo] [["video/cg.mp4"]]
layabox[419:23284] 2 [-1] [JSProxy] [playVideo] [["video/cg.mp4"]]
layabox[419:23284] reflection error: can not find method signature
layabox[419:23284] Received memory warning.
---TS调用部分代码如下:(调用静态方法,其中Android使用方法调用正常)
if (Laya.Render.isConchApp) {
// 通过反射机制,调用Android和IOS原生代码的类和方法
let className = Laya.Browser.onAndriod ? "com.xxxx.yyyy.JSProxy" : "JSProxy";
console.log("className = " + className);
var jsProxy = Laya.PlatformClass.createClass(className);
jsProxy.call("playVideo", url);
}
---JSProxy.h
#import <Foundation/Foundation.h>
@interface JSProxy : NSObject
+(void)playVideo: (NSString*) url; // 只支持对象类型String类型用NSString
@end
---JSProxy.mm
#import "JSProxy.h"
#import "ViewController.h"
#import <conchRuntime.h>
@implementation JSProxy
+(void)playVideo: (NSString*) url
{
NSLog(@"playVideo");
// 静态函数回调通知JS层
[[conchRuntime GetIOSConchRuntime] runJS: @"video.end()"];
}
@end
请问,代码什么地方有问题,如果修改?谢谢!
没有找到相关结果
已邀请:
2 个回复
Monica - 知识达人
赞同来自:
iOS函数签名要加:
if(android){
jsProxy.call("playVideo", url);
}
else if (iOS){
jsProxy.call("playVideo:", url);
}
ylyuan35
赞同来自: