UIPickerView是iOS中的原生选择器控件,使用方便,用法简单,效果漂亮。

@property(nonatomic,assign) id<UIPickerViewDataSource> dataSource;

@property(nonatomic,assign) id<UIPickerViewDelegate>   delegate;

设置数据源和代理

@property(nonatomic) BOOL showsSelectionIndicator;

是否显示选择框,在iOS7之后这个属性没有任何效果

@property(nonatomic,readonly) NSInteger numberOfComponents;

获取分区数

- (NSInteger)numberOfRowsInComponent:(NSInteger)component;

获取某一分区的行数

- (CGSize)rowSizeForComponent:(NSInteger)component;

获取某一分区行的尺寸

- (UIView *)viewForRow:(NSInteger)row forComponent:(NSInteger)component;

获取某一分区某一行的视图

- (void)reloadAllComponents;

重载所有分区

- (void)reloadComponent:(NSInteger)component;

重载某一分区

- (void)selectRow:(NSInteger)row inComponent:(NSInteger)component animated:(BOOL)animated;

设置选中某一分区某一行

- (NSInteger)selectedRowInComponent:(NSInteger)component;

返回某一分区选中的行

数据源代理中的方法:

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;

设置分区数

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;

根据分区设置行数

代理中的方法:

- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component;

设置分区宽度

- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component;

设置分区行高

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;

设置某一行显示的标题

- (NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component;

通过属性字符串设置某一行显示的标题

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view;

设置某一行显示的view视图

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component;

选中某一行时执行的回调

iOS中UIPickerView常见属性和方法的总结的更多相关文章

  1. iOS开发UIScrollView常见属性和方法

    一.ScrollView常用方法和属性 @property(nonatomic)CGPoint contentOffset; 设置滚动的偏移量 @property(nonatomic)CGSize c ...

  2. iOS webView的常见属性和方法

    一.初始化与三种加载方式 UIWebView继承与UIView,因此,其初始化方法和一般的view一样,通过alloc和init进行初始化,其加载数据的方式有三种: 第一种: - (void)load ...

  3. IOS中图片拉伸技巧与方法总结(转载)

    以下内容转载自:http://my.oschina.net/u/2340880/blog/403996 IOS中图片拉伸技巧与方法总结 一.了解几个图像拉伸的函数和方法 1.直接拉伸法 简单暴力,却是 ...

  4. ListBox项模板中绑定ListBoxItem属性的方法

    原文:ListBox项模板中绑定ListBoxItem属性的方法 <ListBox> <ListBox.ItemTemplate> <DataTemplate> & ...

  5. JavaScript的事件对象中的特殊属性和方法(鼠标,键盘)

    鼠标操作导致的事件对象中的特殊属性和方法 鼠标事件是 Web 上面最常用的一类事件,毕竟鼠标还是最主要的定位设备.那么通过事件对象可以获取到鼠标按钮信息和屏幕坐标获取等 鼠标按钮 只有在主鼠标按钮被单 ...

  6. JavaScript中Number常用属性和方法

    title: JavaScript中Number常用属性和方法 toc: false date: 2018-10-13 12:31:42 Number.MAX_VALUE--1.79769313486 ...

  7. IL角度理解C#中字段,属性与方法的区别

    IL角度理解C#中字段,属性与方法的区别 1.字段,属性与方法的区别 字段的本质是变量,直接在类或者结构体中声明.类或者结构体中会有实例字段,静态字段等(静态字段可实现内存共享功能,比如数学上的pi就 ...

  8. UIPickerView常见属性、常见方法(包括代理方法和数据源方法)的一些说明

    一.UIPickerView 1.UIPickerView的常见属性 // 数据源(用来告诉UIPickerView有多少列多少行) @property(nonatomic,assign) id< ...

  9. iOS 中的类属性

    转自:iOS 知识小集 从Xcode 8开始,LLVM已经支持Objective-C显式声明类属性了,这是为了与Swift中的类属性互操作而引入的.在WWDC 2016 What's New in L ...

随机推荐

  1. 【bzoj2751】[HAOI2012]容易题(easy) 数论,简单题

    Description 为了使得大家高兴,小Q特意出个自认为的简单题(easy)来满足大家,这道简单题是描述如下:有一个数列A已知对于所有的A[i]都是1~n的自然数,并且知道对于一些A[i]不能取哪 ...

  2. 森林 BZOJ 3123

    题解: 第k大直接用主席树解决 合并利用启发式合并,将较小的连接到较大的树上 #include<cmath> #include<cstdio> #include<cstd ...

  3. Codeforces 515E Drazil and Park (ST表)

    题目链接 Drazil and Park 中文题面 传送门 如果他选择了x和y,那么他消耗的能量为dx + dx + 1 + ... + dy - 1 + 2 * (hx + hy). 把这个式子写成 ...

  4. windows redis 服务安装坑

    环境 winserver 2012 最新版的redis:3.0.503 redis-server.exe   --service-install   redis.windows.conf    --m ...

  5. BUPT复试专题—日期(2013)

    题目描述 请你计算出第年月日是第X年的第几天.其中,1月1日是第一天,1月2日是第二天,以此类推. 计算时请注意闰年的影响.对于非整百年,年数能整除4是闰年,否则不是闰年:对于整百年,年数能整除400 ...

  6. Android的activity的生命周期

    activity的生命周期有四个重要的状态:活动,暂停,停止,销毁 基本的方法有:onCreate.onStart.onResume.onPause.onStop.onDestory 最经常使用的方法 ...

  7. docker nginx镜像+phpfpm 镜像 组合配置 搭建 PHP+nginx 环境

    前言 在以往的容器环境部署中 运行环境 我们通常把 类似 apache nginx php 等 打包在一个镜像中 起一个容器. 这样做的好处是 方便 简单. 不便的地方是 如果PHP 需要扩展新的 相 ...

  8. POJ 3518 Prime Gap(素数)

    POJ 3518 Prime Gap(素数) id=3518">http://poj.org/problem? id=3518 题意: 给你一个数.假设该数是素数就输出0. 否则输出比 ...

  9. Eclipse中移除native层编译支持

    1. .project 文件 删除全部包括 org.eclipse.cdt前缀的xml结点元素.以下是一个包括cdt的完整编译配置文件. <?xml version="1.0" ...

  10. postgres源码目录结构

    1.第一级目录介绍 |_postgres |_aclocal.m4------------config用的文件的一部分 |_config----------------config文件目录 |_con ...