[已解决] 关于pageView里的不能监听事件

想做一个pageView,从官方test入手,复制了一份,然后,因为官方实例里添加了一个事件监听器,用于每次滑动后获得当前显示的page的index,但是,在web上运行没问题,能获取到当前page的index,但是,在win32和android下,这个事件监听不会触发,不是获取不到index,而是事件根本没有触发,下面上代码

var HelloWorldLayer = cc.Layer.extend({
sprite:null,
helloLabel: null,
ctor:function () {

    this._super();

    var size = cc.winSize;

    this.helloLabel = new cc.LabelTTF("0", "Arial", 38);
    this.helloLabel.x = size.width / 2;
    this.helloLabel.y = size.height / 2 + 200;
    this.addChild(this.helloLabel, 5);
    //
    //
    this.sprite = new cc.Sprite(res.HelloWorld_png);
    this.sprite.attr({
        x: size.width / 2,
        y: size.height / 2
    });
    this.addChild(this.sprite, 0);


    var pageView = new ccui.PageView();
    pageView.setTouchEnabled(true);
    pageView.setContentSize(500, 800);
    pageView.x = size.width / 2;
    pageView.y = size.height / 2;

    for (var i = 0; i < 3; ++i) {
        var layout = new ccui.Layout();
        layout.setContentSize(500, 800);
        var layoutRect = layout.getContentSize();

        var imageView = new ccui.ImageView();
        imageView.setTouchEnabled(true);
        imageView.setScale9Enabled(true);
        imageView.loadTexture("res/scrollviewbg.png");
        imageView.setContentSize(500, 800);
        imageView.x = layoutRect.width / 2;
        imageView.y = layoutRect.height / 2;
        layout.addChild(imageView);

        var text = new ccui.Text();
        text.string = "page" + (i + 1);
        text.font = "30px 'Marker Felt'";
        text.fontSize = 50;
        text.color = cc.color(192, 192, 192);
        text.x = layoutRect.width / 2;
        text.y = layoutRect.height / 2;
        layout.addChild(text);

        pageView.addPage(layout);
    }
    pageView.addEventListener(this.pageViewEvent,this);//**_就是这个事件监听器,在web上没问题,在win32和安卓下不能触发_**
    pageView.setAnchorPoint(0.5,0.5);
    this.addChild(pageView);
    cc.log("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

    return true;
},
pageViewEvent: function (sender, type) {
    cc.log("ccccccccccccc");
    switch (type) {
        case ccui.PageView.EVENT_TURNING:
            var pageView = sender;
            this.helloLabel.setString("page = " + (pageView.getCurPageIndex().valueOf() + 1));
            break;
        default:
            break;
    }


}

});

希望大神或官方人员解答一下,感激不尽

引擎的版本号是多少?

引擎版本是cocos2d-x- 3.10,感激不尽

3.10 是有这个 bug,目前 3.11 版本已经修复。

https://github.com/cocos2d/cocos2d-x/pull/14964/files

https://github.com/cocos2d/cocos2d-x/pull/15018

1赞

好的,谢谢,我试试看

3.11 版本还没有发布,你需要去 github 上面去取,或者你应用一下上面的 PR。

好的,我正在下载你github上的3.11

也遇到了这个问题,通过addEventListener、addClickEventListener添加的监听事件无效,用addCCSEventListener倒是可以响应。

已解决,子龙山人github上的3.11版本修复了这个BUG,不过我不会用github,我是对照着他修改过的地方修改我的引擎源文件

1赞

@zilong大大帮我看看这个问题是怎么回事,谢谢

http://forum.cocos.com/t/web-animate/36294