Skip to content

Commit

Permalink
Merge pull request cocos2d#13966 from zilongshanren/fix-xcode7-overri…
Browse files Browse the repository at this point in the history
…de-issue

CCScrollView should override removeChild
  • Loading branch information
pandamicro committed Sep 21, 2015
2 parents eec67ea + 1c40f7b commit 49f6a86
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
23 changes: 23 additions & 0 deletions extensions/GUI/CCScrollView/CCScrollView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,29 @@ void ScrollView::addChild(Node * child, int zOrder, int tag)
}
}

void ScrollView::removeChild(Node* node, bool cleanup)
{
if(_container != node)
{
_container->removeChild(node, cleanup);
}
else
{
Layer::removeChild(node, cleanup);
}
}

void ScrollView::removeAllChildrenWithCleanup(bool cleanup)
{
_container->removeAllChildrenWithCleanup(cleanup);
Layer::removeAllChildrenWithCleanup(cleanup);
}

void ScrollView::removeAllChildren()
{
removeAllChildrenWithCleanup(true);
}

void ScrollView::addChild(Node * child, int zOrder, const std::string &name)
{
if (_container != child)
Expand Down
3 changes: 3 additions & 0 deletions extensions/GUI/CCScrollView/CCScrollView.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ class CC_EX_DLL ScrollView : public Layer, public ActionTweenDelegate
virtual void addChild(Node * child, int zOrder, int tag) override;
virtual void addChild(Node * child, int zOrder, const std::string &name) override;

virtual void removeAllChildren() override;
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
virtual void removeChild(Node* child, bool cleaup = true) override;
/**
* CCActionTweenDelegate
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ bool TableViewTest::init()
this->addChild(tableView);
tableView->reloadData();

auto testNode = Node::create();
testNode->setName("testNode");
tableView->addChild(testNode);
tableView->removeChild(testNode, true);
CCAssert(nullptr == tableView->getChildByName("testNode"), "The added child has been removed!");


tableView = TableView::create(this, Size(60, 250));
tableView->setDirection(ScrollView::Direction::VERTICAL);
tableView->setPosition(Vec2(winSize.width-150,winSize.height/2-120));
Expand Down

0 comments on commit 49f6a86

Please sign in to comment.