请选择 进入手机版 | 继续访问电脑版
查看: 10969|回复: 26

[app] CrossApp学习进度(“汇浦”应用)

[复制链接]
最佳答案
0 
hu__yong 发表于 2015-9-16 16:34:58 | 显示全部楼层 |阅读模式
最近一直在研究CA,将我们的原应用“汇浦”,用CA尝试着重写了一下,今天来做个简单的汇报。
先附上IOS截图

IMG_0304.jpg
IMG_0305.jpg
IMG_0306.jpg
IMG_0307.jpg
最佳答案
0 
foggy 发表于 2015-9-16 16:37:05 | 显示全部楼层
不错····支持一下···········
最佳答案
0 
 楼主| hu__yong 发表于 2015-9-16 16:38:58 | 显示全部楼层
由于用C++3DES解密原服务器JAVA加密数据,一直没有搞成,折腾了一两个星期,最后还是用了IOS ANDROID各自平台的加解密,但是我还是希望用C++。
最佳答案
0 
 楼主| hu__yong 发表于 2015-9-16 16:54:02 | 显示全部楼层
搜索控件好像没有,就放了个编辑框,不过我看到官方IM的截图里有好看的搜索框,但是源码里没有找到,好像也是只放了编辑框,难道IM的截图不是放出来的源码编译的
最佳答案
0 
天之岩 发表于 2015-9-17 00:43:57 | 显示全部楼层
楼主能把其中几个界面开源一下吗 让我学习一下

点评

以上是四个主页的源码  详情 回复 发表于 2015-9-17 08:55
// // FourthViewController.h // Huipu // // Created by huyong on 15/8/22. // // #ifndef __Huipu__FourthViewController__ #define __Huipu__FourthViewController__ #include #include "CrossApp.h" US  详情 回复 发表于 2015-9-17 08:53
// // ThirdViewController.h // Huipu // // Created by huyong on 15/8/22. // // #ifndef __Huipu__ThirdViewController__ #define __Huipu__ThirdViewController__ #include #include "CrossApp.h" USING  详情 回复 发表于 2015-9-17 08:52
// // SecondViewController.h // Huipu // // Created by huyong on 15/8/22. // // #ifndef __Huipu__SecondViewController__ #define __Huipu__SecondViewController__ #include #include "CrossApp.h" #in  详情 回复 发表于 2015-9-17 08:51
// // FirstViewController.h // Huipu // // Created by huyong on 15/8/22. // // #ifndef __Huipu__FirstViewController__ #define __Huipu__FirstViewController__ #include #include "CrossApp.h" USING  详情 回复 发表于 2015-9-17 08:49
最佳答案
0 
 楼主| hu__yong 发表于 2015-9-17 08:49:35 | 显示全部楼层
天之岩 发表于 2015-9-17 00:43
楼主能把其中几个界面开源一下吗 让我学习一下

//
//  FirstViewController.h
//  Huipu
//
//  Created by huyong on 15/8/22.
//
//

#ifndef __Huipu__FirstViewController__
#define __Huipu__FirstViewController__

#include <iostream>
#include "CrossApp.h"

USING_NS_CC;


class FirstViewController: public CAViewController,
                           public CAPageViewDelegate,
                           public CATableViewDataSource,
                           public CATableViewDelegate
{
   
public:

        FirstViewController();
        virtual ~FirstViewController();
   
    //tableview Delegate
    virtual void tableViewDidSelectRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row);
    virtual void tableViewDidDeselectRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row);
   
    virtual CATableViewCell* tableCellAtIndex(CATableView* table,const CCSize& cellSize,unsigned int section,unsigned int row);
    virtual unsigned int numberOfRowsInSection(CATableView* table,unsigned int section);
    virtual unsigned int numberOfSections(CATableView* table);
    virtual unsigned int tableViewHeightForRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row);
   
protected:
   
    void viewDidLoad();
    void viewDidUnload();
   
private:
    void loadPageView();
    void loadTableView();
    void loadNavBarBtn();
   
    void changePageViewIndex(float interval);
   
private:
    CCSize        m_winSize;
    CAPageView*   m_pageView;
    CATableView*  m_tableView;
   
};


#endif /* defined(__Huipu__FirstViewController__) */






//
//  FirstViewController.cpp
//  Huipu
//
//  Created by huyong on 15/8/22.
//
//

#include "FirstViewController.h"
#include "RecommendFriend.h"
#include "MerchantsView.h"
#include "CustomTableCell.h"
#include "UtilManager.h"

#define PAGE_HEIGHT         (_dip(CAApplication::getApplication()->getWinSize().height) > 980 ? 490 : 370)


FirstViewController::FirstViewController()
{
   
}

FirstViewController::~FirstViewController()
{

}

void FirstViewController::viewDidLoad()
{
    m_winSize = this->getView()->getBounds().size;
   
    //加载pageView
    loadPageView();
   
    //加载tableView
    loadTableView();
   
    //加载navBarBtn
    loadNavBarBtn();
   
}


void FirstViewController::loadPageView()
{
    m_pageView = CAPageView::createWithFrame(CADipRect(0, 0, _dip(m_winSize.width) ,PAGE_HEIGHT), CAPageViewDirectionHorizontal);
    m_pageView->setPageViewDelegate(this);
    m_pageView->setCurrPage(0, true);
    CAVector<CAView*> imgList;
    for (int i = 0; i < 4; i++)
    {
        std::string str1 = "image/mainpage/intro%d.png";
        std::string str2 = "image/mainpage/intro%d%d.png";
        CCString* res = NULL;
        if (PAGE_HEIGHT==490)
        {
            res = CCString::createWithFormat("image/mainpage/intro%d.png",i);
        }
        else
        {
            res = CCString::createWithFormat("image/mainpage/intro%d%d.png",i,i);
        }
        CAImageView* imgView = CAImageView::createWithImage(CAImage::create(res->getCString()));
        imgView->setFrame(CCRect(m_pageView->getViewSize().width/3*i,0,m_pageView->getViewSize().width/3,m_pageView->getViewSize().height));
        imgList.pushBack(imgView);
    }
    m_pageView->setViews(imgList);
    this->getView()->addSubview(m_pageView);
   
    CAScheduler::schedule(schedule_selector(FirstViewController::changePageViewIndex), this, 5, UINT_MAX-1, 5, false);
}

void FirstViewController::loadTableView()
{
    m_tableView = CATableView::createWithFrame(CADipRect(0, PAGE_HEIGHT, _dip(m_winSize.width), _dip(m_winSize.height)-PAGE_HEIGHT));
    m_tableView->setTableViewDelegate(this);
    m_tableView->setTableViewDataSource(this);
    m_tableView->setAllowsSelection(true);
    m_tableView->setScrollEnabled(false);
  
    m_tableView->setSeparatorColor(ccc4(215, 215, 215, 255));
    this->getView()->addSubview(m_tableView);
}

void FirstViewController::loadNavBarBtn()
{
   
}

void FirstViewController::changePageViewIndex(float interval)
{
    int number = m_pageView->getPageCount();
    int curpage = m_pageView->getCurrPage();
    if (curpage < number - 1)
    {
        m_pageView->setCurrPage((curpage+1), true);
    }
    else
    {
        m_pageView->setCurrPage(0, false);
    }
}


//tableview Delegate

unsigned int FirstViewController::numberOfSections(CATableView* table)
{
    return 1;
}

unsigned int FirstViewController::numberOfRowsInSection(CATableView* table,unsigned int section)
{
    return 3;
}

unsigned int FirstViewController::tableViewHeightForRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row)
{
    return  _px((_dip(m_winSize.height)-PAGE_HEIGHT)/3);
}

CATableViewCell* FirstViewController::tableCellAtIndex(CATableView* table,const CCSize& cellSize,unsigned int section,unsigned int row)
{
    CustomTableCell* cell = dynamic_cast<CustomTableCell*>(table->dequeueReusableCellWithIdentifier("HuipuCell"));
    if (cell == NULL)
    {
        std::string szTitle[]    = {"推荐朋友","特约商户","轻松开户"};
        std::string szSubTitle[] = {"邀请好友参与 让债权流转更便捷","接受债权抵付货款 畅享融货服务","享用更多功能 轻松玩转债权流转"};
        std::string szImage[]    = {"image/mainpage/p1_recommend.png","image/mainpage/p1_specialcust.png","image/mainpage/p1_easyregist.png"};
        
        cell = CustomTableCell::create("HuipuCell");
        CALabel* title = CALabel::createWithFrame(CADipRect(100,(_dip(cellSize.height)-(35+30))/2,320,35));
        title->setText(szTitle[row]);
        title->setColor(CAColor_black);
        title->setTextAlignment(CATextAlignmentLeft);
        title->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
        title->setFontSize(_px(30));
        cell->addSubview(title);
        
        CALabel* subtitle = CALabel::createWithFrame(CADipRect(100,(_dip(cellSize.height)-(35+30))/2+45,400,30));
        subtitle->setText(szSubTitle[row]);
        subtitle->setColor(CAColor_gray);
        subtitle->setTextAlignment(CATextAlignmentLeft);
        subtitle->setVerticalTextAlignmet(CAVerticalTextAlignmentTop);
        subtitle->setFontSize(_px(23));
        cell->addSubview(subtitle);
        
        CAImageView* imgView1 = CAImageView::createWithFrame(CADipRect(20,(_dip(cellSize.height)-73)/2,62,73));
        imgView1->setImage(CAImage::create(szImage[row]));
        cell->addSubview(imgView1);
        
        CAImageView* imgView2 = CAImageView::createWithFrame(CADipRect(_dip(cellSize.width)-50,(_dip(cellSize.height)-35)/2,35,35));
        imgView2->setImage(CAImage::create(TABLECELL_ARROW1));
        cell->addSubview(imgView2);
        
        
    }
   
    return cell;
}

void FirstViewController::tableViewDidSelectRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row)
{
    table->setUnSelectRowAtIndexPath(section,row);
   
   
    if (row == 0)
    {//推荐朋友
        RecommendFriend* pRecommend = new RecommendFriend();
        pRecommend->init();
        
        CANavigationController* nav =  new CANavigationController();
        nav->setNavigationBarTitleColor(CAColor_black);
        nav->setNavigationBarBackGroundImage(CAImage::create(NAV_HEAD_BACKGROUND));
        nav->initWithRootViewController(pRecommend);
        UtilManager::getRootViewController()->pushViewController(nav, true);
        
        pRecommend->release();
        nav->release();
    }
    else if (row == 1)
    {//特约商户
        MerchantsView* pMerchant = new MerchantsView();
        pMerchant->init();
        
        CANavigationController* nav =  new CANavigationController();
        nav->setNavigationBarTitleColor(CAColor_black);
        nav->setNavigationBarBackGroundImage(CAImage::create(NAV_HEAD_BACKGROUND));
        nav->initWithRootViewController(pMerchant);
        UtilManager::getRootViewController()->pushViewController(nav, true);
        
        pMerchant->release();
        nav->release();
    }
    else if (row == 2)
    {//轻松开户
        
    }
   
}

void FirstViewController::tableViewDidDeselectRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row)
{
   
}

void FirstViewController::viewDidUnload()
{
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
   
    CAScheduler::unscheduleAllForTarget(this);
}
最佳答案
0 
 楼主| hu__yong 发表于 2015-9-17 08:51:53 | 显示全部楼层
天之岩 发表于 2015-9-17 00:43
楼主能把其中几个界面开源一下吗 让我学习一下

//
//  SecondViewController.h
//  Huipu
//
//  Created by huyong on 15/8/22.
//
//

#ifndef __Huipu__SecondViewController__
#define __Huipu__SecondViewController__

#include <stdio.h>
#include "CrossApp.h"
#include "CrossAppExt.h"

USING_NS_CC;
USING_NS_CC_EXT;

class SecondViewController: public CAViewController,
                            public CATableViewDataSource,
                            public CATableViewDelegate,
                            public CAMediaDelegate
{
   
public:
   
    SecondViewController();
    virtual ~SecondViewController();
   
   
    //tableview Delegate
    virtual void tableViewDidSelectRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row);
    virtual void tableViewDidDeselectRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row);
   
    virtual CAView* tableViewSectionViewForHeaderInSection(CATableView* table, const CCSize& viewSize, unsigned int section);
    virtual CATableViewCell* tableCellAtIndex(CATableView* table,const CCSize& cellSize,unsigned int section,unsigned int row);
    virtual unsigned int numberOfRowsInSection(CATableView* table,unsigned int section);
    virtual unsigned int numberOfSections(CATableView* table);
    virtual unsigned int tableViewHeightForHeaderInSection(CATableView* table, unsigned int section);
    virtual unsigned int tableViewHeightForRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row);
   
    //mediaDelegate
    virtual void getSelectedImage(CAImage* image);
   
protected:
   
    void viewDidLoad();
    void viewDidUnload();
   
    void loadTableView();
    void loadNavBarBtn();
   
    void messageManage(CAControl* btn,CCPoint point);
    void scanClick(CAControl* btn,CCPoint point);
   
private:
    CCSize        m_winSize;
    CATableView*  m_tableView;
   
};

#endif /* defined(__Huipu__SecondViewController__) */






//
//  SecondViewController.cpp
//  Huipu
//
//  Created by huyong on 15/8/22.
//
//

#include "SecondViewController.h"
#include "CustomTableCell.h"
#include "UtilManager.h"

SecondViewController::SecondViewController()
{
   
}

SecondViewController::~SecondViewController()
{
   
}

void SecondViewController::viewDidLoad()
{
    m_winSize = this->getView()->getBounds().size;
   
    //加载tableView
    loadTableView();
   
    //加载navBarBtn
    loadNavBarBtn();
}

void SecondViewController::loadTableView()
{
    m_tableView = CATableView::createWithFrame(CADipRect(0, 0, _dip(m_winSize.width), _dip(m_winSize.height)));
    m_tableView->setTableViewDelegate(this);
    m_tableView->setTableViewDataSource(this);
    m_tableView->setAllowsSelection(true);
    if(CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
        m_tableView->setBackGroundColor(ccc4(237, 237, 237, 255));
    m_tableView->setSeparatorColor(ccc4(215, 215, 215, 255));
    this->getView()->addSubview(m_tableView);
}

void SecondViewController::loadNavBarBtn()
{
    CABarButtonItem* barBtnLeft = CABarButtonItem::create("消息", CAImage::create("image/mainpage/p2_menu_msg.png"),
                                                          CAImage::create("image/mainpage/p2_menu_msg.png"));
    barBtnLeft->setTarget(this, CAControl_selector(SecondViewController::messageManage));
   
    CABarButtonItem* barBtnRight = CABarButtonItem::create("扫一扫", CAImage::create("image/mainpage/p2_menu_scan.png"),
                                                           CAImage::create("image/mainpage/p2_menu_scan.png"));
    barBtnRight->setTarget(this, CAControl_selector(SecondViewController::scanClick));
   
    CANavigationBarItem* barItem = CANavigationBarItem::create("发现");
    barItem->addLeftButtonItem(barBtnLeft);
    barItem->addRightButtonItem(barBtnRight);
    this->setNavigationBarItem(barItem);
}


//tableview Delegate

unsigned int SecondViewController::numberOfSections(CATableView* table)
{
    return 3;
}

unsigned int SecondViewController::numberOfRowsInSection(CATableView* table,unsigned int section)
{
    return 2;
}

unsigned int SecondViewController::tableViewHeightForHeaderInSection(CATableView* table, unsigned int section)
{
    return _px(25);
}

unsigned int SecondViewController::tableViewHeightForRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row)
{
    return _px(100);
}

CAView* SecondViewController::tableViewSectionViewForHeaderInSection(CATableView* table, const CCSize& viewSize, unsigned int section)
{
    CAView* view = CAView::createWithColor(ccc4(237, 237, 237, 255));
    return view;
}

CATableViewCell* SecondViewController::tableCellAtIndex(CATableView* table,const CCSize& cellSize,unsigned int section,unsigned int row)
{
    CustomTableCell* cell = dynamic_cast<CustomTableCell*>(table->dequeueReusableCellWithIdentifier("HuipuCell2"));
    if (cell == NULL)
    {
        std::string szTitle[][2]    = {{"我的好友","朋友圈"},{"投资债权","金融机构"},{"附近商家","优惠券"}};
        std::string szImage[][2]    = {{"image/mainpage/p2_myfriend.png","image/mainpage/p2_friends.png"},
                                      {"image/mainpage/p2_investion.png","image/mainpage/p2_financial.png"},
                                      {"image/mainpage/p2_near.png","image/mainpage/p2_youhui.png"}};
        
        cell = CustomTableCell::create("HuipuCell2");
        CALabel* title = CALabel::createWithFrame(CADipRect(100,(_dip(cellSize.height)-35)/2,320,35));
        title->setText(szTitle[section][row]);
        title->setColor(CAColor_black);
        title->setTextAlignment(CATextAlignmentLeft);
        title->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
        title->setFontSize(_px(30));
        cell->addSubview(title);
        

        CAImageView* imgView1 = CAImageView::createWithFrame(CADipRect(20,(_dip(cellSize.height)-60)/2,60,60));
        imgView1->setImage(CAImage::create(szImage[section][row]));
        cell->addSubview(imgView1);
        
        CAImageView* imgView2 = CAImageView::createWithFrame(CADipRect(_dip(cellSize.width)-50,(_dip(cellSize.height)-35)/2,35,35));
        imgView2->setImage(CAImage::create(TABLECELL_ARROW4));
        cell->addSubview(imgView2);
    }
   
    return cell;
}

void SecondViewController::tableViewDidSelectRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row)
{
    table->setUnSelectRowAtIndexPath(section,row);
}

void SecondViewController::tableViewDidDeselectRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row)
{
   
}


//消息管理
void SecondViewController::messageManage(CAControl* btn,CCPoint point)
{
    //CADevice:penAlbum(this);
}

//扫一扫
void SecondViewController::scanClick(CAControl* btn,CCPoint point)
{
    //CADevice:penCamera(this);
}

//mediaDelegate
void SecondViewController::getSelectedImage(CAImage* image)
{
   
}

void SecondViewController::viewDidUnload()
{
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

最佳答案
0 
 楼主| hu__yong 发表于 2015-9-17 08:52:46 | 显示全部楼层
天之岩 发表于 2015-9-17 00:43
楼主能把其中几个界面开源一下吗 让我学习一下

//
//  ThirdViewController.h
//  Huipu
//
//  Created by huyong on 15/8/22.
//
//

#ifndef __Huipu__ThirdViewController__
#define __Huipu__ThirdViewController__

#include <stdio.h>
#include "CrossApp.h"

USING_NS_CC;

class ThirdViewController: public CAViewController,
                           public CATableViewDataSource,
                           public CATableViewDelegate
{
   
public:
   
    ThirdViewController();
    virtual ~ThirdViewController();
   
    //tableview Delegate
    virtual void tableViewDidSelectRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row);
    virtual void tableViewDidDeselectRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row);
   
    virtual CAView* tableViewSectionViewForHeaderInSection(CATableView* table, const CCSize& viewSize, unsigned int section);
    virtual CATableViewCell* tableCellAtIndex(CATableView* table,const CCSize& cellSize,unsigned int section,unsigned int row);
    virtual unsigned int numberOfRowsInSection(CATableView* table,unsigned int section);
    virtual unsigned int numberOfSections(CATableView* table);
    virtual unsigned int tableViewHeightForHeaderInSection(CATableView* table, unsigned int section);
    virtual unsigned int tableViewHeightForRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row);
   
   
protected:
   
    void viewDidLoad();
    void viewDidUnload();
   
    void loadTableView();
    void loadNavBarBtn();
   
private:
    CCSize        m_winSize;
    CATableView*  m_tableView;
};


#endif /* defined(__Huipu__ThirdViewController__) */







//
//  ThirdViewController.cpp
//  Huipu
//
//  Created by huyong on 15/8/22.
//
//

#include "ThirdViewController.h"
#include "CustomTableCell.h"
#include "UtilManager.h"

ThirdViewController::ThirdViewController()
{
   
}

ThirdViewController::~ThirdViewController()
{
   
}

void ThirdViewController::viewDidLoad()
{
    m_winSize = this->getView()->getBounds().size;
   
    //加载tableView
    loadTableView();
   
    //加载navBarBtn
    loadNavBarBtn();
}

void ThirdViewController::loadTableView()
{
    m_tableView = CATableView::createWithFrame(CADipRect(0, 0, _dip(m_winSize.width), _dip(m_winSize.height)));
    m_tableView->setTableViewDelegate(this);
    m_tableView->setTableViewDataSource(this);
    m_tableView->setAllowsSelection(true);
    if(CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
        m_tableView->setBackGroundColor(ccc4(237, 237, 237, 255));
    m_tableView->setSeparatorColor(ccc4(215, 215, 215, 255));
    this->getView()->addSubview(m_tableView);
}

void ThirdViewController::loadNavBarBtn()
{
   
}

//tableview Delegate

unsigned int ThirdViewController::numberOfSections(CATableView* table)
{
    return 3;
}

unsigned int ThirdViewController::numberOfRowsInSection(CATableView* table,unsigned int section)
{
    if(section == 1)
        return 4;
    return 2;
}

unsigned int ThirdViewController::tableViewHeightForHeaderInSection(CATableView* table, unsigned int section)
{
    return _px(25);
}

unsigned int ThirdViewController::tableViewHeightForRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row)
{
    return _px(100);
}

CAView* ThirdViewController::tableViewSectionViewForHeaderInSection(CATableView* table, const CCSize& viewSize, unsigned int section)
{
    CAView* view = CAView::createWithColor(ccc4(237, 237, 237, 255));
    return view;
}

CATableViewCell* ThirdViewController::tableCellAtIndex(CATableView* table,const CCSize& cellSize,unsigned int section,unsigned int row)
{
    CustomTableCell* cell = dynamic_cast<CustomTableCell*>(table->dequeueReusableCellWithIdentifier("HuipuCell2"));
    if (cell == NULL)
    {
        std::string szTitle[][4]    = {{"债权余额","资金余额","",""},{"持有明细","变动明细","出让债权","受让确认"},
                                       {"债权融资","应收应付","",""}};
        std::string szImage[][4]    = {{"image/mainpage/p3_accountmoney.png", "image/mainpage/p3_accountmoney.png","",""},
                                       {"image/mainpage/p3_hold.png",         "image/mainpage/p3_change.png",
                                        "image/mainpage/p3_transfer.png",     "image/mainpage/p3_recieve.png"},
                                       {"image/mainpage/p3_publish.png",      "image/mainpage/p3_payrecv.png","",""}};
        
        cell = CustomTableCell::create("HuipuCell2");
        CALabel* title = CALabel::createWithFrame(CADipRect(100,(_dip(cellSize.height)-35)/2,320,35));
        title->setText(szTitle[section][row]);
        title->setColor(CAColor_black);
        title->setTextAlignment(CATextAlignmentLeft);
        title->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
        title->setFontSize(_px(30));
        cell->addSubview(title);
        
        
        CAImageView* imgView1 = CAImageView::createWithFrame(CADipRect(20,(_dip(cellSize.height)-60)/2,60,60));
        imgView1->setImage(CAImage::create(szImage[section][row]));
        cell->addSubview(imgView1);
        
        if (section == 0 && row == 0)
        {
        }
        else
        {
            CAImageView* imgView2 = CAImageView::createWithFrame(CADipRect(_dip(cellSize.width)-50,(_dip(cellSize.height)-35)/2,35,35));
            imgView2->setImage(CAImage::create(TABLECELL_ARROW4));
            cell->addSubview(imgView2);
        }
    }
   
   
    return cell;
}

void ThirdViewController::tableViewDidSelectRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row)
{
    table->setUnSelectRowAtIndexPath(section,row);
   
}

void ThirdViewController::tableViewDidDeselectRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row)
{
   
}


void ThirdViewController::viewDidUnload()
{
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


最佳答案
0 
 楼主| hu__yong 发表于 2015-9-17 08:53:34 | 显示全部楼层
天之岩 发表于 2015-9-17 00:43
楼主能把其中几个界面开源一下吗 让我学习一下

//
//  FourthViewController.h
//  Huipu
//
//  Created by huyong on 15/8/22.
//
//

#ifndef __Huipu__FourthViewController__
#define __Huipu__FourthViewController__

#include <stdio.h>
#include "CrossApp.h"

USING_NS_CC;

class FourthViewController: public CAViewController,
                            public CATableViewDataSource,
                            public CATableViewDelegate
{
   
public:
   
    FourthViewController();
    virtual ~FourthViewController();
   
    //tableview Delegate
    virtual void tableViewDidSelectRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row);
    virtual void tableViewDidDeselectRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row);
   
    virtual CAView* tableViewSectionViewForHeaderInSection(CATableView* table, const CCSize& viewSize, unsigned int section);
    virtual CATableViewCell* tableCellAtIndex(CATableView* table,const CCSize& cellSize,unsigned int section,unsigned int row);
    virtual unsigned int numberOfRowsInSection(CATableView* table,unsigned int section);
    virtual unsigned int numberOfSections(CATableView* table);
    virtual unsigned int tableViewHeightForHeaderInSection(CATableView* table, unsigned int section);
    virtual unsigned int tableViewHeightForRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row);
   
protected:
    void viewDidAppear();
    void viewDidLoad();
    void viewDidUnload();
   
    void loadTableView();
    void loadNavBarBtn();
   
    void aboutInfo(CAControl* btn,CCPoint point);
   
private:
    CCSize        m_winSize;
    CATableView*  m_tableView;
};


#endif /* defined(__Huipu__FourthViewController__) */




//
//  FourthViewController.cpp
//  Huipu
//
//  Created by huyong on 15/8/22.
//
//

#include "FourthViewController.h"
#include "CustomTableCell.h"
#include "UtilManager.h"
#include "AboutUsView.h"
#include "LoginView.h"

FourthViewController::FourthViewController()
{
   
}

FourthViewController::~FourthViewController()
{
   
}

void FourthViewController::viewDidAppear()
{
    if (m_tableView != NULL)
    {
        m_tableView->reloadData();
    }
}

void FourthViewController::viewDidLoad()
{
    m_winSize = this->getView()->getBounds().size;
   
    //加载tableView
    loadTableView();
   
    //加载navBarBtn
    loadNavBarBtn();
}

void FourthViewController::loadTableView()
{
    m_tableView = CATableView::createWithFrame(CADipRect(0, 0, _dip(m_winSize.width), _dip(m_winSize.height)));
    m_tableView->setTableViewDelegate(this);
    m_tableView->setTableViewDataSource(this);
    m_tableView->setAllowsSelection(true);
    if(CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
        m_tableView->setBackGroundColor(ccc4(237, 237, 237, 255));
    m_tableView->setSeparatorColor(ccc4(215, 215, 215, 255));
    this->getView()->addSubview(m_tableView);
}

void FourthViewController::loadNavBarBtn()
{
    CABarButtonItem* barBtnRight = CABarButtonItem::create("关于", CAImage::create("image/mainpage/p4_about.png"),
                                                                  CAImage::create("image/mainpage/p4_about.png"));
    barBtnRight->setTarget(this, CAControl_selector(FourthViewController::aboutInfo));
   
    CANavigationBarItem* barItem = CANavigationBarItem::create("更多");
    barItem->addRightButtonItem(barBtnRight);
    this->setNavigationBarItem(barItem);
}

//tableview Delegate

unsigned int FourthViewController::numberOfSections(CATableView* table)
{
    return 5;
}

unsigned int FourthViewController::numberOfRowsInSection(CATableView* table,unsigned int section)
{
    if(section == 0 || section == 1)
        return 1;
    return 2;
}

unsigned int FourthViewController::tableViewHeightForHeaderInSection(CATableView* table, unsigned int section)
{
    if(section == 0)
        return _px(0);
   
    return _px(25);
}

unsigned int FourthViewController::tableViewHeightForRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row)
{
    if(section == 0)
    {
        if (UtilManager::shareUtilManager()->getLoginState())
        {
            return _px(200);
        }
        else
        {
            return _px(240);
        }
    }
   
    return _px(100);
}

CAView* FourthViewController::tableViewSectionViewForHeaderInSection(CATableView* table, const CCSize& viewSize, unsigned int section)
{
    if(section == 0)
        return NULL;
   
    CAView* view = CAView::createWithColor(ccc4(237, 237, 237, 255));
    return view;
}

CATableViewCell* FourthViewController::tableCellAtIndex(CATableView* table,const CCSize& cellSize,unsigned int section,unsigned int row)
{
    CustomTableCell* cell = NULL;//dynamic_cast<CustomTableCell*>(table->dequeueReusableCellWithIdentifier("HuipuCell2"));
    //if (cell == NULL)
    {
        std::string szTitle[][2]    = {{"",""},{"公告资讯",""},{"我的银行卡","常用客户"},
                                       {"修改登录密码","修改转让密码"},{"客服中心","开户网点"}};
        std::string szImage[][2]    = {{"image/mainpage/p4_login.png", ""},{"image/mainpage/p4_notice.png",""},
                                       {"image/mainpage/p4_yhk.png",  "image/mainpage/p4_commonuser.png"},
                                       {"image/mainpage/p4_set.png",  "image/mainpage/p4_safe.png"},
                                       {"image/mainpage/p4_micro.png","image/mainpage/p4_wd.png"}};
        
        cell = CustomTableCell::create("HuipuCell2");
        CALabel* title = CALabel::createWithFrame(CADipRect(100,(_dip(cellSize.height)-35)/2,320,35));
        title->setText(szTitle[section][row]);
        title->setColor(CAColor_black);
        title->setTextAlignment(CATextAlignmentLeft);
        title->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
        title->setFontSize(_px(30));
        cell->addSubview(title);
        
        if (section == 0 && row == 0)
        {
            if (UtilManager::shareUtilManager()->getLoginState())
            {//已登录
                //头像
                CAImageView* imgView2 = CAImageView::createWithFrame(CADipRect(20,40,110,110));
                imgView2->setImage(CAImage::create(HEADIMG_DEFAULT));
                cell->addSubview(imgView2);
               
                //客户名称
                CALabel* custnamelabel = CALabel::createWithFrame(CADipRect(160,10,_dip(cellSize.width)-40,80));
                string custname = UtilManager::shareUtilManager()->getCustName();
                custnamelabel->setText(custname.length()==0 ? "--" : custname);
                custnamelabel->setColor(CAColor_black);
                custnamelabel->setTextAlignment(CATextAlignmentLeft);
                custnamelabel->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
                custnamelabel->setNumberOfLine(2);
                custnamelabel->setFontSize(_px(32));
                cell->addSubview(custnamelabel);
               
                //客户号
                CALabel* custnolabel = CALabel::createWithFrame(CADipRect(160,80,100,50));
                custnolabel->setText("客户号:");
                custnolabel->setColor(CAColor_gray);
                custnolabel->setTextAlignment(CATextAlignmentLeft);
                custnolabel->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
                custnolabel->setFontSize(_px(28));
                cell->addSubview(custnolabel);
               
                CALabel* custnolab = CALabel::createWithFrame(CADipRect(260,80,_dip(cellSize.width)-260,50));
                string custno = UtilManager::shareUtilManager()->getCustNo();
                custnolab->setText(custno.length()==0 ? "--" : custno);
                custnolab->setColor(CAColor_black);
                custnolab->setTextAlignment(CATextAlignmentLeft);
                custnolab->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
                custnolab->setFontSize(_px(30));
                cell->addSubview(custnolab);
               
                //电话
                CALabel* tellab = CALabel::createWithFrame(CADipRect(160,130,100,50));
                tellab->setText("电话:");
                tellab->setColor(CAColor_gray);
                tellab->setTextAlignment(CATextAlignmentLeft);
                tellab->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
                tellab->setFontSize(_px(28));
                cell->addSubview(tellab);
               
                CALabel* tellabel = CALabel::createWithFrame(CADipRect(260,130,_dip(cellSize.width)-260,50));
                string tel = UtilManager::shareUtilManager()->getMobile();
                tellabel->setText(tel.length()==0 ? "--" : tel);
                tellabel->setColor(CAColor_black);
                tellabel->setTextAlignment(CATextAlignmentLeft);
                tellabel->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
                tellabel->setFontSize(_px(30));
                cell->addSubview(tellabel);
            }
            else
            {//未登录
                CAImageView*imgBack = CAImageView::createWithFrame(CADipRect(0,0,_dip(cellSize.width),_dip(cellSize.height)));
                imgBack->setImage(CAImage::create(szImage[section][row]));
                cell->addSubview(imgBack);
            }
        }
        else
        {
            CAImageView* imgView = CAImageView::createWithFrame(CADipRect(20,(_dip(cellSize.height)-60)/2,60,60));
            imgView->setImage(CAImage::create(szImage[section][row]));
            cell->addSubview(imgView);
        }
        
        if (section == 0 && row == 0 && !UtilManager::shareUtilManager()->getLoginState())
        {
        }
        else
        {
            CAImageView* imgArrow = CAImageView::createWithFrame(CADipRect(_dip(cellSize.width)-50,(_dip(cellSize.height)-35)/2,35,35));
            imgArrow->setImage(CAImage::create(TABLECELL_ARROW4));
            cell->addSubview(imgArrow);
        }
    }
   
   
    return cell;
}

void FourthViewController::tableViewDidSelectRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row)
{
    table->setUnSelectRowAtIndexPath(section,row);
   
    if ((section == 1 && row == 0) || (section == 4 && row == 0))
    {//客服中心、公告资讯不判断
    }
    else
    {
        //判断是否登录
        if (!UtilManager::shareUtilManager()->getLoginState())
        {
            LoginView* pLogin = new LoginView();
            pLogin->init();
            
            CANavigationController* nav =  new CANavigationController();
            nav->setNavigationBarTitleColor(CAColor_black);
            nav->setNavigationBarBackGroundImage(CAImage::create(NAV_HEAD_BACKGROUND));
            nav->initWithRootViewController(pLogin);
            
            UtilManager::getRootViewController()->presentModalViewController(nav, true);
            pLogin->release();
            nav->release();
   
            return;
        }
        
        if (section == 3 && row == 0)
        {//修改登录密码不判断实名认证
        }
        else
        {
            //登录后 判断是否实名认证了
            if(UtilManager::shareUtilManager()->getLoginState())
            {
                if(!UtilManager::shareUtilManager()->getUserRole() && section != 0)
                {
                    CAAlertView* alertview = CAAlertView::createWithText("提示", "您尚未完成实名认证,暂时不能使用此功能!", "取消", "实名认证", NULL);
                    alertview->show();
                    return;
                }
            }
        }
    }
   
}

void FourthViewController::tableViewDidDeselectRowAtIndexPath(CATableView* table,unsigned int section, unsigned int row)
{
   
}

//关于页面
void FourthViewController::aboutInfo(CAControl* btn,CCPoint point)
{
    AboutUsView* pAboutus = new AboutUsView();
    pAboutus->init();
   
    CANavigationController* nav =  new CANavigationController();
    nav->setNavigationBarTitleColor(CAColor_black);
    nav->setNavigationBarBackGroundImage(CAImage::create(NAV_HEAD_BACKGROUND));
    nav->initWithRootViewController(pAboutus);
   
    UtilManager::getRootViewController()->pushViewController(nav, true);
    pAboutus->release();
    nav->release();
}

void FourthViewController::viewDidUnload()
{
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

推荐阅读 More>

© 2001-2015 9秒社团

合作伙伴

公司简介 | 联系方式
COPYRIGHT©2015 ZHONGQINGLONGTU NETWORK CO.LTD ALL RIGHTS RESERVED.ICP备11023195号-4
北京中清龙图网络技术有限公司
返回顶部 返回列表