Webview doesn't hide when it is inside pageview

  • mihir77
    Likes 0

    Problem Description

     Hi, 

    I have added a pageview, and in that there is a layout and in tht webview, sprite and label. I want to hide everything when a button is clicked.

    But everything else gets hidden but view doesn’t hide. I also declared webview as global varible.

    Even if i hide layout or pageview, everything else hides but not webview. what can i do here.


       

     pageView = PageView :: create ();
        pageView-> ignoreAnchorPointForPosition (false );
       
        pageView-> setContentSize(Size(visibleSize.width, visibleSize.height*0.90));
        pageView->setAnchorPoint(Vec2::ZERO);
        pageView-> setPosition (Vec2 (origin));
        
          
        for(int i = 0; i < 7; i++)
        {
                           
            layout1 = Layout::create();
            layout1-> setContentSize(Size(visibleSize.width, visibleSize.height*0.90));
            layout1->setAnchorPoint(Vec2::ZERO);
            layout1-> setPosition (Vec2 (origin));
            
            
            
            std::string url = "http://www.google.com";
         
            
             _webView = cocos2d::experimental::ui::WebView::create();
          
            _webView->setContentSize(Size(visibleSize.width + origin.x, visibleSize.height*0.80));
            _webView->setAnchorPoint(Size(1,1));
            _webView->setPosition(Vec2(layout1->getPositionX(), layout1->getContentSize().height));
            _webView->setScalesPageToFit(true);
          
             _webView->loadURL(url);
            layout1->addChild(_webView);
           
    
    
    
    Text* label = Text::create(StringUtils::format("page %d",(i)), "fonts/Marker Felt.ttf", 30);
            label->setColor(Color3B(92, 192, 192));
            label->setPosition(Point(layout1->getContentSize().width / 2.0f, layout1->getContentSize().height / 2.0f));
            layout1->addChild(label);
            pageView->addPage(layout1);
        }
        this->addChild(pageView);

     

    And in on click method of a button – 

    I do  –

    _webView->setVisible(false);
            layout1->setVisible(false);
            pageView->setVisible(false);

     

     

     

  • Sonar Systems admin
    Likes 0

    Try deleting the page view and then adding it when you need it.

Login to reply