-
Notifications
You must be signed in to change notification settings - Fork 421
CACollectionViewDataSource
CACollectionView’s data delegate
Access modifier |
Method name |
Description |
public |
collectionCellAtIndex |
Cell’s content |
public |
numberOfSectionsInCollectioView |
Section count |
public |
numberOfRowsInSectionCollectionView |
Each section’s cell count |
public |
collectionViewHeightForHeaderInSection |
Each section’s headerView |
public |
collectionViewHeightForFooterInSection |
Each section’s footerView |
public |
collectionViewSectionViewForHeaderInSection |
HeaderView content |
public |
collectionViewSectionViewForFooterInSection |
footerView content |
public |
numberOfItemsInRowsInSection |
Each vell’s item count |
public |
collectionViewHeightForRowAtIndexPath |
Cell height |
virtual CACollectionViewCell collectionCellAtIndex(CACollectionView collectionView, const CCSize& cellSize, unsigned int section, unsigned int row, unsigned int item) = 0
Return value: CACollectionViewCell*
Parameter:
Type |
Parameter name |
Description |
CACollectionView * |
collectionView |
current collectionView |
const CCSize |
cellSize |
Cell’s size |
unsigned int |
section |
section index value |
unsigned int |
row |
Cell’s index value |
unsigned int |
item |
Cell’s item count |
Description: Same with tableView, cell also deploys multiplexing mode.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
CACollectionViewCell* CollectionViewTest: : collectionCellAtIndex(CACollectionView *collectionView, const CCSize& cellSize, unsigned int section, unsigned int row, unsigned int item) { CACollectionViewCell* p_Cell = collectionView->dequeueReusableCellWithIdentifier("CrossApp"); if (p_Cell == NULL) { p_Cell = CACollectionViewCell: : create("CrossApp"); CAImageView* itemView = CAImageView: : createWithImage(CAImage: : create("logo. png")); itemView->setCenter(CCRect(cellSize. width*0. 5,cellSize. height*0. 5,cellSize. height * 0. 90,cellSize. height * 0. 90)); itemView->setTag(99); p_Cell->addSubview(itemView);
CALabel* itemText = CALabel: : createWithCenter(CCRect(itemView->getBounds(). size. width*0. 5, itemView->getBounds(). size. height*0. 5, itemView->getBounds(). size. width*0. 6, itemView->getBounds(). size. width*0. 5)); itemText->setTag(100); itemText->setFontSize(29 * CROSSAPP_ADPTATION_RATIO); itemText->setTextAlignment(CATextAlignmentCenter); itemText->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); itemView->addSubview(itemText);
} char pos[20] = ""; sprintf(pos, "(%d,%d,%d)",section, row, item); CALabel* itemText = (CALabel*)p_Cell->getSubviewByTag(99)->getSubviewByTag(100); itemText->setText(pos);
return p_Cell; } |
virtual unsigned int numberOfSectionsInCollectioView() { return 1; }
Return value: unsigned int
Description: Return section count of collectionView, and return a section by default.
*virtual unsigned int numberOfRowsInSectionCollectionView(CACollectionView collectionView, unsigned int section) = 0
Return value: unsigned int
Parameter:
Type |
Parameter name |
Description |
CACollectionView * |
collectionView |
current collectionView |
unsigned int |
section |
section index value |
virtual unsigned int collectionViewHeightForHeaderInSection(CACollectionView *collectionView, unsigned int section) { return 0; }
Return value: unsigned int
Parameter:
Type |
Parameter name |
Description |
CACollectionView * |
collectionView |
current collectionView |
unsigned int |
section |
section index value |
virtual unsigned int collectionViewHeightForFooterInSection(CACollectionView *collectionView, unsigned int section) { return 0; }
Return value: unsigned int
Parameter:
Type |
Parameter name |
Description |
CACollectionView * |
collectionView |
current collectionView |
unsigned int |
section |
section index value |
virtual CAView collectionViewSectionViewForHeaderInSection(CACollectionView *collectionView, const CCSize& viewSize, unsigned int section){ return NULL; }*
Return value: CAView*
Parameter:
Type |
Parameter name |
Description |
CACollectionView * |
collectionView |
current collectionView |
const CCSize |
cellSize |
Cell’s size |
unsigned int |
section |
section index value |
virtual CAView collectionViewSectionViewForFooterInSection(CACollectionView *collectionView, const CCSize& viewSize, unsigned int section){ return NULL; }*
Return value: CAView*
Parameter:
Type |
Parameter name |
Description |
CACollectionView * |
collectionView |
current collectionView |
const CCSize |
cellSize |
Cell’s size |
unsigned int |
section |
section index value |
*virtual unsigned int numberOfItemsInRowsInSection(CACollectionView collectionView, unsigned int section, unsigned int row) = 0
Return value: unsigned int
Parameter:
Type |
Parameter name |
Description |
CACollectionView * |
collectionView |
current collectionView |
unsigned int |
section |
section index value |
unsigned int |
row |
Cell’s index value |
virtual unsigned int collectionViewHeightForRowAtIndexPath(CACollectionView collectionView, unsigned int section, unsigned int row) { return 0; }*
Return value: unsigned int
Parameter:
Type |
Parameter name |
Description |
CACollectionView * |
collectionView |
current collectionView |
unsigned int |
section |
section index value |
unsigned int |
row |
Cell’s index value |