ui::UIScrollivew 的大坑

int width =510; // bgLayer->getContentSize().width;
auto scrollLayer =  ui::ScrollView::create();
scrollLayer->setContentSize(Size(width,400));
int height;
int lineHeight=100;
height=scrollLayer->getContentSize().height;
scrollLayer->setInnerContainerSize(Size(width,height));
scrollLayer->setPosition( Point(200,410 ));
scrollLayer->setDirection(ui::SCROLLVIEW_DIR::SCROLLVIEW_DIR_VERTICAL);
layer1->addChild(scrollLayer,1000,1000);

auto test =ui::ImageView::create("new/map/bg_map/worldmap_14.png");
test->setPosition(Point(510 / 2.0f, test->getSize().height / 2.0f));
scrollLayer->addChild(test);

this->addChild(layer1,1111);

如上代码,scrollveiw就是不显示在界面, 尼玛花了半天时间才发现,setContentSize  要改成setSize()即可, 好大的坑


你可能感兴趣的:(cocos)