Пример #1
0
void CAAutoCollectionView::clearData()
{
	m_mpUsedCollectionCells.clear();
	m_rUsedCollectionCellRects.clear();
	m_pSelectedCollectionCells.clear();
	m_rCollectionViewSection.clear();

	for (int i = 0; i < m_vpUsedCollectionCells.size(); i++)
	{
		CACollectionViewCell* cell = m_vpUsedCollectionCells.at(i);
		CC_CONTINUE_IF(cell == NULL);
		m_mpFreedCollectionCells[cell->getReuseIdentifier()].pushBack(cell);
		cell->removeFromSuperview();
		cell->resetCollectionViewCell();
	}
	m_vpUsedCollectionCells.clear();

	m_pHighlightedCollectionCells = NULL;
}
Пример #2
0
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;
}
Пример #3
0
void CACollectionView::recoveryCollectionCell()
{
	CCRect rect = this->getBounds();
	rect.origin = getContentOffset();
	rect.origin.y -= rect.size.height * 0.1f;
	rect.size.height *= 1.2f;

	std::map<CAIndexPath3E, CACollectionViewCell*>::iterator itr;
	for (itr = m_pUsedCollectionCells.begin(); itr != m_pUsedCollectionCells.end(); itr++)
	{
		CACollectionViewCell* cell = itr->second;
		CC_CONTINUE_IF(cell == NULL);

		CCRect cellRect = cell->getFrame();
		CC_CONTINUE_IF(rect.intersectsRect(cellRect));

		m_pFreedCollectionCells[cell->getReuseIdentifier()].pushBack(cell);
		cell->removeFromSuperview();
		cell->resetCollectionViewCell();
		itr->second = NULL;
	}
}