zoukankan      html  css  js  c++  java
  • iOS开发之UIPickerView

    1、使用方法

    UIPickerView使用和UITableView大致类似。首先设置ViewController为数据源,然后遵守数据源协议< UIPickerViewDataRecouce>,之后实现协议中的方法:

    一共有多少列:

    - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)

    pickerView;

    component列显示多少行:

    - (NSInteger)pickerView:(UIPickerView *)pickerView

     numberOfRowsInComponent:(NSInteger)component;

    上面只能设置UIPickerView有多少行、多少列,不能设置数据,如果要显示数据,必须要设置ViewController为UIPickerView的代理,遵守代理协议<UIPickerViewDelegate>,然后实现代理中的方法:

    component列的第row行显示什么文字:

    - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:

    (NSInteger)row forComponent:(NSInteger)component;

    component列第row行显示怎样的view(内容)

    - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:

    (NSInteger)row forComponent:(NSInteger)component reusingView:

    (UIView *)view;

    选中了pickerView的第component列第row

    - (void)pickerView:(UIPickerView *)pickerView didSelectRow:

    (NSInteger)row inComponent:(NSInteger)component

  • 相关阅读:
    第二周教学设计反思
    uni-app,一套代码应用在多个平台
    新CMS
    学习js
    关于数据库
    自己写的一段jquery实现当滚动条滑动到某个位置实现向中间移动
    js平滑滚动到顶部、底部、指定地方
    统一一个帝国中搜索页面的模板
    帝国CMS的总结
    回到顶部的功能
  • 原文地址:https://www.cnblogs.com/lifengfneg/p/4773873.html
Copyright © 2011-2022 走看看