课程表

入门与环境搭建

简单控件的使用

视图控制

调用、存储、网络和动画

其他控件的使用

工具箱
速查手册

视图选择器

当前位置:免费教程 » 移动开发 » CrossApp

类说明

选择器控件,pickerView至少包括一个组件(component),每个组件包括供选择的子项(row)。


基类

CAView,CATableViewDataSource


CAPickerView 属性(点击查看方法介绍)

属性
说明
PickerViewDelegate滑动事件代理
PickerViewDataSource数据代理
FontSizeNormal正常状态下的字体大小
FontSizeSelected选中时的字体大小
FontColorNormal正常状态下的字体颜色
FontColorSelected选中时的字体颜色
SeparateColor选中框的边框颜色


CAPickerView 方法(点击查看方法介绍)

方法说明
create创建,默认Frame为(0,0,0,0)
createWithFrame创建,并指定其Frame,默认Frame为(0,0,0,0)
createWithCenter创建,并设置其Center,默认Center为(0,0,0,0)
init初始化
onEnter进入
onExit退出
visit访问
initWithFrame初始化,并指定其Frame
initWithCenter初始化,并指定其Center
numberOfComponents获取组件的数量
numberOfRowsInComponent获取指定组件的row的数量
rowSizeForComponent获取指定组件的size
viewForRow获取row
reloadAllComponents刷新所有组件
reloadComponent刷新指定组件
selectRow指定选中的row
selectedRowInComponent获取当前被选中的row
setBackgroundColor设置背景颜色


CAPickerView 属性说明

PickerViewDelegate

类型:CAPickerViewDelegate*

解释:pickerView的选中事件代理,包含一个选中时触发的接口,public get/set{}。


PickerViewDataSource

类型:CAPickerViewDataSource*

解释:pickerView的数据代理,详细接口请参考CAPickerViewDataSource代理类,public get/set{}。


FontSizeNormal

类型:float

解释:备选项的字体大小,public get/set{}。


FontSizeSelected

类型:float

解释:选中项的字体大小,public get/set{}。


FontColorNormal

类型:CAColor4B

解释:备选项的字体颜色,public get/set{}。


FontColorSelected

类型:CAColor4B

解释:选中项的字体颜色,public get/set{}。


SeparateColor

类型:CAColor4B

解释:选框的边框颜色,public get/set{}。


CAPickerView 方法说明

static CAPickerView* create();

返回值:CAPickerView*

参数:

解释:创建,默认Frame为(0,0,0,0)


static CAPickerView* createWithFrame(const DRect& rect);

返回值:CAPickerView*

参数:

类型
参数名说明
DRect&rect区域大小

解释:创建,并指定其Frame,默认Frame为(0,0,0,0)


static CAPickerView* createWithCenter(const DRect& rect);

返回值:CAPickerView*

参数:

类型
参数名说明
DRect&rect中心点的位置及大小

解释:创建,并设置其Center,默认Center为(0,0,0,0)


virtual bool init();

返回值:bool

参数:

解释:初始化


virtual void onEnter();

返回值:void

参数:

解释:进入


virtual void onExit();

返回值:void

参数:

解释:退出


virtual void visit();

返回值:void

参数:

解释:访问


virtual bool initWithFrame(const DRect& rect);

返回值:bool

参数:

类型
参数名说明
DRect&rect区域大小

解释:初始化,并指定其Frame


virtual bool initWithCenter(const DRect& rect);

返回值:bool

参数:

类型
参数名说明
DRect&rect中心点的位置及大小

解释:初始化,并指定其Center


virtual int numberOfComponents();

返回值:int

参数:

解释:获取组件的数量


virtual int numberOfComponents()

返回值:int

参数:

解释:返回pickerView中component的数量


virtual int numberOfRowsInComponent(unsigned int component)

返回值:int

参数:

类型
参数说明
unsigned intcomponent指定的component

解释:返回pickerView中component的数量


virtual CCSize rowSizeForComponent(unsigned int component)

返回值:CCSize

参数:

类型
参数说明
unsigned intcomponent指定的component

解释:获取指定组件的size


virtual CAView* viewForRow(unsigned int row, unsigned int component)

返回值:CAView*

参数:

类型
参数说明
unsigned introw指定的row
unsigned int component指定的component

解释:获取row


virtual void reloadAllComponents()

返回值:void

参数:

解释:刷新所有的组件,创建pickerView时必须手动刷新一次pickerView。

示例:

  1. pickerView = CAPickerView::createWithCenter(CCRect(size.width*0.5, size.height*0.5, size.width*0.6, size.height*0.5));
  2. pickerView->setDelegate(this);
  3. pickerView->setDataSource(this);
  4. pickerView->setFontSizeNormal(30 * CROSSAPP_ADPTATION_RATIO);
  5. pickerView->setFontSizeSelected(30 * CROSSAPP_ADPTATION_RATIO);
  6. pickerView->setFontColorNormal(CAColor_blueStyle);
  7. pickerView->setFontColorSelected(CAColor_blueStyle);
  8. pickerView->setSeparateColor(CAColor_blueStyle);
  9. pickerView->reloadAllComponents();
  10. this->getView()->addSubview(pickerView);

virtual void reloadComponent(unsigned int component, bool bReload = true)

返回值:void

参数:

类型
参数说明
unsigned intcomponent指定的component
boolbReload可选参数

解释:刷新指定组件


virtual void selectRow(unsigned int row, unsigned int component, bool animated = false)

返回值:void

参数:

类型
参数说明
unsigned introw指定的row
unsigned intcomponent指定的component
boolanimated可选参数

解释:指定选中的row


virtual int selectedRowInComponent(unsigned int component)

返回值:int

参数:

类型
参数说明
unsigned intcomponent指定的component

解释:获取当前被选中的row


virtual void setBackgroundColor(const CAColor4B& color);    

返回值:void

参数:

类型
参数名说明
CAColor4B&color颜色

解释:设置背景颜色

转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号