Skip to content
9miao Mobile Game edited this page Aug 14, 2014 · 2 revisions

CAPageView Detailed Description

Class Description

Paging and page turning class, it’s able to implement scroll page turning effect.

Effect Picture

Base Class

CAScrollView

Attribute

access modifier

Attribute name

Description

protected

PageViewDirection

scrolling direction

protected

PageViewDelegate

scrolling event delegate

protected

CurrPage

current page serial number

Method

access modifier

Method name

Description

public

getPageCount

pageView total pages

public

setViews

build pageView

Attribute Description

PageViewDirection

Type: CAPageViewDirection

Description: pageView’s scrolling direction, enumeration type including horizontal and vertical directions, public get/set{}.

1

2

3

4

5

    typedef enum

    {

        CAPageViewDirectionHorizontal,

        CAPageViewDirectionVertical

    }CAPageViewDirection;

Example:

1

   pageViewTest = CAPageView: : createWithCenter(CCRect(size. width*0. 5, size. height*0. 5, size. width, size. height), CAPageView: : CAPageViewDirectionVertical);

PageViewDelegate

Type: CAPageViewDelegate*

Description: pageView scrolling event’s delegate, please refer to the detailed interfaces of delegate class: CAPageViewDelegate, public get/set{}.

CurrPage

Type: int
Description: current pages, public get/set{}.

Method Description

int getPageCount()
Return value: int
Description: obtain pageView total pages

void setViews(CAVector vec)
Return value: void
Parameter:

Type

Parameter name

Description

CAVector

vec

build pageView array

Description: An array of views are needed to transfer as page element of pageView when building pageView.

Example:

1

2

3

4

5

6

7

8

9

10

11

    CAImageView* view1 = CAImageView: : createWithImage(CAImage: : create("bg. jpg"));

    CAImageView* view2 = CAImageView: : createWithImage(CAImage: : create("2. jpg"));

    CAView* view3 = CAView: : createWithColor(CAColor_green);

    _view. pushBack(view1);

    _view. pushBack(view2);

    _view. pushBack(view3);

      

    pageViewTest = CAPageView: : createWithCenter(CCRect(size. width*0. 5, size. height*0. 5, size. width, size. height), CAPageView: : CAPageViewDirectionVertical);

    pageViewTest->setPageViewDelegate(this);

    pageViewTest->setViews(_view);

    this->getView()->addSubview(pageViewTest);

Usage reference

Please refer to pageView’s detailed usage in CAPageViewTest example of CrossApp official Demo, path: CrossApp \samples\demo\Classes\PageViewTest.

Clone this wiki locally