帖子
帖子
用户
博客
课程
显示全部楼层
6
帖子
0
勋章
43
Y币

[superwebview] html向原生发送事件失败。

[复制链接]
发表于 2016-1-15 14:12:52
本帖最后由 知了火舞 于 2016-1-15 14:14 编辑

ios端代码:
[[APIEventCenter defaultCenter] addEventListener:self  selectorselector(handleEvent name"Test"];

- (void)handleEventAPIEvent *)event {
    NSString *msg = [NSString stringWithFormat"收到来自Html5的%@事件,传入的参数为:%@", event.name, event];
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle"" message:msg delegate:nil cancelButtonTitle"确定" otherButtonTitles:nil, nil];
    [alert show];
}
html端代码:
api.sendEvent({
            name: 'Test',
            extra: commend
        });

不执行或者说没有效果,你们官方的demo是可以的,自己新建一个prject就不好使了。,不知道是哪里需要特别的设置?


28
帖子
1
勋章
1万+
Y币
首先得确认sendEvent的代码是否执行到了,你可以在config.xml里面配置下<preference name="debug" value="true"/>,如果js代码有错误会弹出提示。
您需要登录后才可以回帖 登录

本版积分规则