Skip to content
9miao edited this page Oct 10, 2014 · 4 revisions

CACollectionView

Class Description

It’s similar to CATableView, implement tableView’s basic functions, mainly used to expand tableView and display data in a more perfect way.

Effect Picture


Base Class

CAScrollView

Attribute

Access modifier

Attribute name

Description

protected

CollectionViewDataSource

data delegate

protected

CollectionViewDelegate

click event delegate

protected

CollectionHeaderView

section’s header view

protected

CollectionFooterView

section footer view

protected

CollectionHeaderHeight

header view height

protected

CollectionFooterHeight

footer view height

protected

HoriInterval

horizontal interval between item

protected

VertInterval

vertical interval between item

protected

AllowsSelection

cell is allowed to select or not

protected

AllowsMultipleSelection

cell is allowed to multiple seclect or not

protected

AlwaysTopSectionHeader

section header stays at the top or not

protected

AlwaysBottomSectionFooter

section footer stays at the top or not

Method

Access modifier

Method name

Description

public

reloadData

refresh tableView

 

public

setSelectRowAtIndexPath

set current selected item

 

public

dequeueReusableCellWithIdentifier

Search designated identifier’s cell from reuse queue.

Attribute Description

CollectionViewDataSource
Type: CACollectionViewDataSource*
Descripiton: data delegate is required to set when using collectionView, please refer to detailed interface of delegate class: CACollectionViewDataSource,public get/set{}.
Example:
CACollectionView* p_Conllection=CACollectionView: : createWithCenter(CCRect(size. width*0. 5,size. height*0. 5,size. width,size. height));
p_Conllection->setCollectionViewDataSource(this);
this->getView()->addSubview(p_Conllection);

CollectionViewDelegate
Type: CACollectionViewDelegate*
Descripiton: Click event delegate, delegate class includes interfaces that responds to selected cell and interface that cancels selected cell. you can set this delegate according to actual conditions, please refer to its detailed interface in CACollectionViewDelegate, public get/set{}.
Example:
CACollectionView* p_Conllection=CACollectionView: : createWithCenter(CCRect(size. width*0. 5,size. height*0. 5,size. width,size. height));
p_Conllection->setCollectionViewDelegate(this);
p_Conllection->setCollectionViewDataSource(this);
this->getView()->addSubview(p_Conllection);

CollectionHeaderView
Type: CAView*
Descripiton: collectionView’s header view, get/set{}.

CollectionFooterView
Type: CAView*
Descripiton: collectionView’s footer view, get/set{}.

CollectionHeaderHeight
Type: unsigned int
Descripiton: collectionView’s header view height, get/set{}.

CollectionFooterHeight
Type: unsigned int
Descripiton: collectionView’s footer view height, public get/set{}.

HoriInterval
Type: unsigned int
Descripiton: item’s horizontal interval, a cell in collectionView can be divided into several items, get/set{}.

VertInterval
Type: unsigned int
Descripiton: vertical interval between item, get/set{}.

AllowsSelection
Type: bool
Descripiton: cell is selectable or not, is/set{}.
Example:
CACollectionView* p_Conllection=CACollectionView: : createWithCenter(CCRect(size. width*0. 5,size. height*0. 5,size. width,size. height));
p_Conllection->setCollectionViewDelegate(this);
p_Conllection->setCollectionViewDataSource(this);
p_Conllection->setAllowsSelection(true);
this->getView()->addSubview(p_Conllection);

AllowsMultipleSelection
Type: bool
Descripiton: cell is multi-selectable or not, it must be set as selectable for multi-select setting, public is/set{}.
Example:
CACollectionView* p_Conllection=CACollectionView: : createWithCenter(CCRect(size. width*0. 5,size. height*0. 5,size. width,size. height));
p_Conllection->setCollectionViewDelegate(this);
p_Conllection->setCollectionViewDataSource(this);
p_Conllection->setAllowsSelection(true);
p_Conllection->setAllowsMultipleSelection(true);
this->getView()->addSubview(p_Conllection);

AlwaysTopSectionHeader
Type: bool
Descripiton: allow sectionHeader alway stays tableView’ top or not when cell is sliding out of interface, true by default, is/set{}.

AlwaysBottomSectionFooter
Type: bool
Descripiton: allow sectionFooter alway stays tableView’ bottom or not when cell is sliding out of interface, true by default, is/set{}.

Method Description

void reloadData()
Return value: void
Descripiton: refresh current collectionView, this method will be called to do a force refresh for any data change in collectionView.

void setSelectRowAtIndexPath(unsigned int section, unsigned int row, unsigned int item)
Return value: void
Parameter:

Type

Parameter name

Description

unsigned int

section

clicked section

unsigned int

row

selected cell

unsigned int

item

selected item

Descripiton: you can set the selected data of current collectionView by calling this interface.

CACollectionViewCell dequeueReusableCellWithIdentifier(const char reuseIdentifier)**
Return value: CACollectionViewCell*
Parameter:

Type

Parameter name

Description

const char*

reuseIdentifier

reuse identifier

Descripiton: search designated identifier’s cell from reuse queue, and return NULL if cell does not exist.
Clone this wiki locally