CACollectionViewCell* CACollectionViewCell::create(const std::string& reuseIdentifier) { CACollectionViewCell* cell = new CACollectionViewCell(); if (cell && cell->initWithReuseIdentifier(reuseIdentifier)) { cell->autorelease(); return cell; } CC_SAFE_DELETE(cell); return NULL; }
CACollectionViewCell* ThirdViewController::collectionCellAtIndex(CACollectionView *collectionView, const CCSize& cellSize, unsigned int section, unsigned int row, unsigned int item) { CACollectionViewCell* pCell = new CACollectionViewCell(); char cIdentifier[1024] = { 0 }; sprintf(cIdentifier, "{%d, %d, %d}" ,section, row, item); pCell->initWithReuseIdentifier(cIdentifier); CALabel* label = CALabel::createWithCenter(CCRectMake(cellSize.width / 2, cellSize.height - 30, cellSize.width, cellSize.height)); label->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); label->setTextAlignment(CATextAlignmentCenter); label->setFontSize(28); label->setText(pCell->getReuseIdentifier()); pCell->addSubview(label); CAImageView* pCellImage = CAImageView::createWithCenter(CCRectMake(cellSize.width / 2, cellSize.height / 2 - 20, cellSize.width*0.7f, cellSize.height*0.7f)); pCell->addSubview(pCellImage); pCellImage->setImageAsyncWithFile("1.jpg"); return pCell; }