博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UIPickerView的使用
阅读量:7069 次
发布时间:2019-06-28

本文共 1282 字,大约阅读时间需要 4 分钟。

代理方法

<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];

转载于:https://www.cnblogs.com/yutingliuyl/p/7351173.html

你可能感兴趣的文章
Preemption Context Switches 和 Synchronization Context Switches
查看>>
UVA 10405 Longest Common Subsequence (动态规划 LCS)
查看>>
CURL常用命令
查看>>
阿里巴巴技术团队博客
查看>>
java 单例模式
查看>>
IIS8 使用FastCGI配置PHP环境支持 过程详解
查看>>
互联网TCP/IP五层模型(一)
查看>>
ftrace 简介【转】
查看>>
用H5中的Canvas等技术制作海报
查看>>
python正则表达式匹配时间和IP地址
查看>>
【三石jQuery视频教程】01.图片循环展示
查看>>
matlab std函数 用法及实例
查看>>
【linux shell系列--1】crontab命令
查看>>
电脑运行 apk
查看>>
PHPExcel读取Excel文件
查看>>
最近写的一个Win8的看漫画程序
查看>>
centos中使用python遇到的几个问题
查看>>
JBOSS在win7环境下启动run.bat无反应
查看>>
redux源码解析
查看>>
我是如何设计 Upload 上传组件的
查看>>