zoukankan      html  css  js  c++  java
  • UIPickerView的使用

    代理方法

    <UIPickerViewDataSource,UIPickerViewDelegate>

    初始化

        self.selectPicker.delegate = self;
        self.selectPicker.dataSource = self;
        self.selectPicker.frame = CGRectMake(0, 480, 320, 216) ;


    代理方法

    显示pickerview的components的个数

    - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
        return 1;
        
    }

    显示每一个components的rows
    - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
        return [pickerArray count];
    }

    //显示每一行的title
    -(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
        return [pickerArray objectAtIndex:row];
    }








    1 UIPickerView
    选择器
    //   设置picker的数据源和代理。目的是将来为了调用协议方法
        picker.dataSource = self;
        picker.delegate = self;
    //  设置显示中间的那两条线(选择指示器)
        picker.showsSelectionIndicator = YES;
    #pragma mark 标记


    2 协议方法分为两种 必须实现的协议方法 @required
                        可选择的协议方法             @optional
    3 //  获取两列中已经选择的行号
         _firstRow = [pickerView selectedRowInComponent:0];
        _secondRow = [pickerView selectedRowInComponent:1];


    //  指定显示某列某行
        [_picker selectRow:1 inComponent:0 animated:YES];
        [_picker selectRow:1 inComponent:1 animated:YES];


    又一次载入(刷新) 全部 的 列
       reloadAllComponents 会又一次的调用pickerView的全部的与pickerView构建和显示相关的协议方法。
        [_picker reloadAllComponents];

    指定刷新某列
        [_picker reloadComponent:0];

  • 相关阅读:
    PostgreSQL使用MySQL外表(mysql_fdw)
    使用node+puppeteer+express搭建截图服务
    零碎知识
    miniconda 搭建tensorflow框架
    有效需求分析阅读笔记(六)
    有效需求分析阅读笔记(五)
    索引原理和优势
    存储过程的优缺点
    RestSharp
    在vue中安装sass/scss报错
  • 原文地址:https://www.cnblogs.com/yutingliuyl/p/7351173.html
Copyright © 2011-2022 走看看