赞
踩
js端代码:
-
-
- export default class JsbUtils {
- public static callVibration(data: any): void {
- if (CC_JSB) {
- // @ts-ignore
- jsb.reflection.callStaticMethod('JsBridge', 'sayMe');
- jsb.reflection.callStaticMethod('JsBridge', 'callVibration:', data);
- }
- }
-
- }
- export const jsbUtils = new JsbUtils();
OC: JsBridge.h
-
- #import <Foundation/Foundation.h>
- #import <UIKit/UIKit.h>
-
- NS_ASSUME_NONNULL_BEGIN
-
- @interface JsBridge : NSObject
- + (void)callVibration:(NSString *)withName;
- + (void)sayMe;
- @end
-
- NS_ASSUME_NONNULL_END
JsBridge.m
- #import "JsBridge.h"
-
- @implementation JsBridge
- + (void)callVibration:(NSString *)withName {
- NSLog(@"withName is %@",withName);
- NSLog(@"hello");
- UIImpactFeedbackGenerator* generator = [[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleMedium];
- [generator impactOccurred];
- }
- + (void)sayMe {
- NSLog(@"sayMe");
- }
- @end
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。