示例#1
0
bool CATabBarController::initWithViewControllers(const std::vector<CAViewController*>& viewControllers)
{
    CAViewController::init();
    
    do
    {
        CC_BREAK_IF(viewControllers.size() == 0);
        m_pViewControllers.insert(m_pViewControllers.begin(), viewControllers.begin(), viewControllers.end());
        
        std::vector<CATabBarItem*> items;
        
        for (unsigned int i=0; i<m_pViewControllers.size(); i++)
        {
            CAViewController* view = m_pViewControllers.at(i);
            view->retain();
            view->m_pTabBarController = this;
            if (view->getTabBarItem() == NULL)
            {
                const char* title = CCString::createWithFormat("item%d",i)->getCString();
                CATabBarItem* item = CATabBarItem::create(title, NULL, i);
                view->setTabBarItem(item);
            }
            items.push_back(view->getTabBarItem());
        }
        
        m_pTabBar = CATabBar::create(items);
        m_pTabBar->retain();
        m_pTabBar->setDelegate(this);
    }
    while (0);
    
    return true;
    
}
示例#2
0
CAViewController* CANavigationController::popViewControllerAtIndex(int index)
{
    if (index >= m_pViewControllers.size() || index < 0)
    {
        return NULL;
    }
    
    if (index == m_pViewControllers.size() - 1)
    {
        return this->popViewControllerAnimated(false);
    }
    
    CAViewController* viewController = m_pViewControllers.at(index);
    viewController->viewDidDisappear();
    viewController->m_pNavigationController = NULL;
    viewController->removeViewFromSuperview();
    viewController->retain()->autorelease();
    m_pViewControllers.erase(index);
    
    m_pContainers.at(index)->removeFromSuperview();
    m_pContainers.erase(index);
    
    m_pSecondContainers.erase(index);
    
    m_pNavigationBars.erase(index);
    
    return viewController;
}
示例#3
0
void CANavigationController::viewDidLoad()
{
    CAViewController* viewController = m_pViewControllers.front();
    viewController->retain()->autorelease();
    m_pViewControllers.popFront();
    this->createWithContainer(viewController);
    
    m_tNavigationBarSize = m_pNavigationBars.front()->getFrame().size;
    
    this->layoutNewContainer();
}
示例#4
0
void CANavigationController::popViewControllerFinish()
{
    CAViewController* lastViewController = m_pViewControllers.back();
    lastViewController->viewDidDisappear();
    lastViewController->m_pNavigationController = NULL;
    lastViewController->removeViewFromSuperview();
    lastViewController->retain()->autorelease();
    m_pViewControllers.popBack();
    m_pNavigationBar->popItem();
    CAViewController* showViewController = m_pViewControllers.back();
    showViewController->getView()->setFrameOrigin(CCPointZero);
}
bool CATabBarController::initWithViewControllers(const std::vector<CAViewController*>& viewControllers, CABarVerticalAlignment var)
{
    CAViewController::init();

    do
    {
        CC_BREAK_IF(viewControllers.size() == 0);
        m_pViewControllers.insert(m_pViewControllers.begin(), viewControllers.begin(), viewControllers.end());

        std::vector<CATabBarItem*> items;

        for (unsigned int i=0; i<m_pViewControllers.size(); i++)
        {
            CAViewController* view = m_pViewControllers.at(i);
            view->retain();
            view->m_pTabBarController = this;
            if (view->getTabBarItem() == NULL)
            {
                const char* title = CCString::createWithFormat("item%d",i)->getCString();
                CATabBarItem* item = CATabBarItem::create(title, NULL);
                item->setTag(i);
                view->setTabBarItem(item);
            }
            items.push_back(view->getTabBarItem());
        }

        m_pTabBar = CATabBar::create(items);
        m_pTabBar->retain();
        m_pTabBar->setAnchorPoint(CCPointZero);
        m_pTabBar->setDelegate(this);

        m_pContainer = new CAScrollView();
        m_pContainer->initWithFrame(CCRectZero);
        m_pContainer->setScrollEnabled(false);
        m_pContainer->setBounces(false);
        m_pContainer->setShowsHorizontalScrollIndicator(false);
        m_pContainer->setShowsVerticalScrollIndicator(false);

    }
    while (0);

    m_eTabBarVerticalAlignment = var;

    return true;

}
示例#6
0
void CANavigationController::replaceViewControllerFinish()
{
    CAViewController* lastViewController = m_pViewControllers.back();
    lastViewController->retain()->autorelease();
    m_pViewControllers.popBack();
    m_pNavigationBar->popItem();
    lastViewController->viewDidDisappear();
    lastViewController->removeViewFromSuperview();
    
    CAViewController* viewController = m_pViewControllers.back();
    viewController->getView()->setFrameOrigin(CCPointZero);
    if (viewController->getNavigationBarItem() == NULL && viewController->getTitle().compare("") != 0)
    {
        viewController->setNavigationBarItem(CANavigationBarItem::create(viewController->getTitle()));
    }
    m_pNavigationBar->pushItem(viewController->getNavigationBarItem());
}
示例#7
0
void CANavigationController::popViewControllerFinish()
{
    CAViewController* backViewController = m_pViewControllers.back();
    backViewController->viewDidDisappear();
    backViewController->m_pNavigationController = NULL;
    backViewController->removeViewFromSuperview();
    backViewController->retain()->autorelease();
    m_pViewControllers.popBack();
    
    m_pContainers.back()->removeFromSuperview();
    m_pContainers.popBack();
    
    m_pSecondContainers.popBack();
    
    m_pNavigationBars.popBack();
    
    m_pContainers.back()->setFrameOrigin(DPointZero);
    
    CAApplication::getApplication()->getTouchDispatcher()->setDispatchEventsTrue();
}
示例#8
0
void CANavigationController::replaceViewControllerFinish()
{
    CAView* newContainer = m_pContainers.back();
    newContainer->setFrameOrigin(CCPointZero);
    
    size_t index = m_pViewControllers.size() - 2;
    
    CAViewController* lastViewController = m_pViewControllers.at(index);
    lastViewController->viewDidDisappear();
    lastViewController->m_pNavigationController = NULL;
    lastViewController->removeViewFromSuperview();
    lastViewController->retain()->autorelease();
    m_pViewControllers.erase(index);
    
    CAView* backContainer = m_pContainers.at(index);
    backContainer->removeFromSuperview();
    m_pContainers.erase(index);
    
    m_pNavigationBars.erase(index);
    CAApplication::getApplication()->getTouchDispatcher()->setDispatchEventsTrue();
}
示例#9
0
CAViewController* CANavigationController::popFirstViewController()
{
    if (m_pViewControllers.size() <= 1)
    {
        return NULL;
    }
    
    CAViewController* frontViewController = m_pViewControllers.front();
    frontViewController->viewDidDisappear();
    frontViewController->m_pNavigationController = NULL;
    frontViewController->removeViewFromSuperview();
    frontViewController->retain()->autorelease();
    m_pViewControllers.popFront();
    
    m_pContainers.front()->removeFromSuperview();
    m_pContainers.popFront();
    
    m_pSecondContainers.popFront();
    
    m_pNavigationBars.popFront();
    
    return frontViewController;
}