1、必须把当前的UILayer的优先级设置为1,priority的数值越大,优先级越低
- m_uiLayer = UILayer::create();
- UIWidget *m_uiLayerWidget = GUIReader::shareReader()->widgetFromJsonFile(shopBlackPath"ui_layout_shop_black.json");
- CCAssert(m_uiLayerWidget, "");
- m_uiLayer->addWidget(m_uiLayerWidget);
- this->addChild(m_uiLayer, 1);
- m_uiLayer->setTouchPriority(1);
2、必须把CCtableView里面的layer的优先级设置为2,。防止穿透点击tableView里面的按钮。
- CCTableViewCell* ShopBlackLayer::tableCellAtIndex(CCTableView *table, unsigned int idx)
- {
- CCTableViewCell *cell = table->dequeueCell();
- if (!cell)
- {
-
- cell = new CCTableViewCell();
- cell->autorelease();
- }
- else
- {cell->removeAllChildrenWithCleanup(true);}
-
- UIWidget *widget = m_cellWidget->clone();
- widget->setTag(idx);
-
- UILayer *layer = UILayer::create();
- layer->addWidget(widget);
- layer->setTouchPriority(2);
-
- cell->addChild(layer);
- return cell;
- }
3、必须把Panel_top和Panel_bottom的渲染层级设置为0,而把其他需要接受点击的按钮的渲染层级设置为比Panel。这样就把屏蔽了tableview的点击穿透了。Panel_top设置为可交互。