c++ - cocos2dx : Issue when returning multiple numberOfCellsInTableView in CCTableViwe?

标签 c++ iphone ios7 cocos2d-x

我正在使用 CCTableView 在 cocos2dx 中创建多个表格 View 。当我定义 DataSource 方法“numberOfCellsInTableView”时,我想为不同的 TableView 返回不同的值。

所以我使用了 if-control 语句。

但我似乎无法正确检查条件。

我的 CCLayer 类的 inti 方法中的代码如下:-

    CCLOG("init debug 10 %d",characterImageNameArray->count());

    numberOfRowsIncharacterTable = characterImageNameArray->count();

    this->characterTable = cocos2d::extension::CCTableView::create(this,cocos2d::CCSizeMake((winSize.width/6.0)-20, winSize.height-720.0));

其余定义如下:-

unsigned int  numberOfCellsInTableView (cocos2d::extension::CCTableView * table)
{
    CCLOG("init debug 11 ");
    int rVal = 0;
    if (table==this->characterTable) {
        CCLOG("init debug 11a ");
        rVal = this->characterImageNameArray->count();
    }
    CCLOG("init debug 12 rVal %d",rVal);
    return rVal;
}

以下是控制台调试日志:-

Cocos2d: init debug 9
Cocos2d: init debug 10 6
Cocos2d: init debug 11 
Cocos2d: init debug 12 rVal 0
Cocos2d: init debug 11 
Cocos2d: init debug 12 rVal 0
Cocos2d: init debug 11 
Cocos2d: init debug 12 rVal 0

我不明白哪里出了问题?

最佳答案

我还在我的场景中展示了不同的表格 View ,并且我采用了不同的方法。

我创建 TableView* my_table_01 = Table_creation.... 然后,我将 TAG_TABLE_01 用作 my_table_01->setTag(TAG_TABLE_01); 等其他表,更改 TAG。

在 numberOfCellsInTableView 中,我决定检查表的 TAG 的单元格数量为:

if (table->getTag() == ....) return number_cells_for_this_table;

您也可以对单元格大小使用相同的方法并拥有多个表格 View 。

关于c++ - cocos2dx : Issue when returning multiple numberOfCellsInTableView in CCTableViwe?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23383910/

相关文章:

c++ - C++ 中的非指针成员函数类型定义?

iphone - UIButton 不显示 iOS6 中的文本

ios - 从 NSArray 对象设置 UIPickerView

c++ - "long"和 "long int"以及 "long long"与 "long long int"之间有什么区别

c++ - 类似于\see 或\sa 的 Doxygen 别名

c++ - std::ios_base::ios_base(const std::ios_base&) 是私有(private)的

iphone - 如果您第一次选择“否”,则 PushNotification 会出现问题

ios - 当客户端连接突然丢失时,Swift XMPP 消息会丢失

visual-studio-2012 - iOS7 在模拟器中测试后台获取?

ios - UIWebView 从后台返回后在 iOS 7 上更改 contentSize