我在testcpp里面UIPageViewButtonTest 添加如下代码(加红部分)会造成pageView在按钮区域无法滑动的情况!
page上面都是有一个layout,layout上面有layer,layer包含了若干个控件,但是这些控件是有事件的,每当我在这些控件上滑动,它会拦截滑动事件,pageView就收不到滑动事件,导致了不可以滑动。
int pageCount = 4;
for (int i = 0; i < pageCount; ++i)
{
HBox* outerBox = HBox::create();
outerBox->setContentSize(Size(240.0f, 130.0f));
for (int k = 0; k < 2; ++k) {
VBox* innerBox = VBox::create();
for (int j = 0; j < 3; j++) {
Button *btn = Button::create("cocosui/animationbuttonnormal.png",
"cocosui/animationbuttonpressed.png");
btn->setName(StringUtils::format("button %d", j));
btn->addTouchEventListener( CC_CALLBACK_2(UIPageViewButtonTest::onButtonClicked, this));
innerBox->addChild(btn);
}
LinearLayoutParameter *parameter = LinearLayoutParameter::create();
parameter->setMargin(Margin(0,0,100,0));
innerBox->setLayoutParameter(parameter);
outerBox->addChild(innerBox);
}
Layout* layout1=Layout::create();
cocos2d::Layer* layer1=Layer::create();
layer1->addChild(outerBox);
layout1->addChild(layer1);
pageView->insertPage(layout1,i);
}
无语了!