使用cocos creator 2.3.3 创建了一个空项目
直接调用 object-c 方法直接报错
[ERROR] (/Applications/CocosCreator/Creator/2.3.3/CocosCreator.app/Contents/Resources/cocos2d-x/cocos/scripting/js-bindings/manual/JavaScriptObjCBridge.mm, 418): call (NativeOcClass.callNativeUIWithTitle:andContent:) failed, result code: -5
不知道这个 -5 代表的是什么意思呢 有大佬知道吗?
目录结构和代码已经贴出来呢
ios代码
#ifndef NativeOcClass_h
#define NativeOcClass_h
import <Foundation/Foundation.h>
@interface NativeOcClass : NSObject
+( void )callNativeUIWithTitle:(NSString *) title andContent:(NSString *)content;
@end
@implementation NativeOcClass
+( void )callNativeUIWithTitle:(NSString *) title andContent:(NSString *)content{
NSLog(@“callNativeUIWithTitle”);
}
@end
#endif /* NativeOcClass_h */
const {ccclass, property} = cc._decorator;
ts 代码
@ccclass
export default class NewClass extends cc.Component {
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
start () {
console.log("startstart");
jsb.reflection.callStaticMethod("NativeOcClass",
"callNativeUIWithTitle:andContent:",
"cocos2d-js",
"Yes! you call a Native UI from Reflection");
}
// update (dt) {}
}
