本系列所有开发文档翻译链接地址:iOS7开发-Apple苹果iPhone开发Xcode官方文档翻译PDF下载地址

 //转载请注明出处--本文永久链接:http://www.cnblogs.com/ChenYilong/p/3495910.html

 

 

本文对应pdf文档下载链接,猛戳—>: UIPikerView的属性.docx
231.0 KB
UIPikerView的属性.pdf
216.9 KB

 

 

UIPikerView的属性
技术博客http://www.cnblogs.com/ChenYilong/   新浪微博http://weibo.com/luohanchenyilong  
numberOfComponents:返回UIPickerView当前的列数
NSInteger num = _pickerView.numberOfComponents;
NSLog( @"%d", num);
2. - (NSInteger)numberOfRowsInComponent:(NSInteger)component; 返回component列中有多少行。
NSInteger numInCp = [_pickerView numberOfRowsInComponent:0];
NSLog(@"%d",numInCp);
3. -  (CGSize)rowSizeForComponent:(NSInteger)component; 返回component中一行的尺寸。

CGSize size = [_pickerView rowSizeForComponent:0];
NSLog(@"%@", NSStringFromCGSize(size));

delegate:
2.0 设置UIPickerView代理
_pickerView.delegate = self;
// 设置UIPickView每行显示的内容
2.1 - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    return @"showData";
}

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

// 返回一个视图,用来设置pickerView的每行显示的内容。
-(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
    UIView *myView=[[UIView alloc]init];
    myView.backgroundColor = [UIColor redColor];
    return myView;
}
效果:

dataSource:数据源
#pragma mark  - dataSource method
// 设置每列显示3行
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    return 3;
}
// 设置显示2列
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 2;
}

技术博客http://www.cnblogs.com/ChenYilong/   新浪微博http://weibo.com/luohanchenyilong  
4. showsSelectionIndicator:是否显示指示器,默认为NO  
_pickerView.showsSelectionIndicator = NO;

注意:设置UIPickerView的行数与列数需要设置数据源,遵守UIPickerViewDataSource,设置UIPickerView的内容需要设置代理,并且遵守代理方法UIPickerViewDelegate。

 //转载请注明出处--本文永久链接:http://www.cnblogs.com/ChenYilong/p/3495910.html

5.-(void)pickerView:(UIPickerView*)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component;
当点击UIPickerView的某一列中某一行的时候,就会调用这个方法。
6. 返回第component列每一行的高度
- (CGFloat)pickerView:(UIPickerView *)pickerView
rowHeightForComponent:(NSInteger)component;

7.刷新某一列的数据
一旦调用了这个方法,就会重新给数据源发送消息计算这列的行数、重新给代理发送消息获得这列的内容
[pickerView reloadComponent:1];
8. 刷新所有列的数据 
- (void)reloadAllComponents;
9. 返回选中的是第component列的第几行。
- (NSInteger)selectedRowInComponent:(NSInteger)component;                                  

 

 

 //转载请注明出处--本文永久链接:http://www.cnblogs.com/ChenYilong/p/3495910.html

本文对应pdf文档下载链接,猛戳—>: https://www.evernote.com/shard/s227/sh/e83d0f72-0fd5-47e8-8e21-e8034ceec714/0b75653fd46c68671d09afe172099b35

本系列所有开发文档翻译链接地址:iOS7开发-Apple苹果iPhone开发Xcode官方文档翻译PDF下载地址

UIPikerView的属性---iOS-Apple苹果官方文档翻译的更多相关文章

  1. iOS数据存取---iOS-Apple苹果官方文档翻译

    CHENYILONG Blog iOS数据存取---iOS-Apple苹果官方文档翻译 数据存取/*技术博客http://www.cnblogs.com/ChenYilong/ 新浪微博http:// ...

  2. iOS网络基础---iOS-Apple苹果官方文档翻译

    CHENYILONG Blog iOS网络基础---iOS-Apple苹果官方文档翻译 iOS网络基础 技术博客http://www.cnblogs.com/ChenYilong/ 新浪微博http: ...

  3. iOS静态库 ---iOS-Apple苹果官方文档翻译

    iOS静态库 ---iOS-Apple苹果官方文档翻译 •什么是库? 库是共享程序代码的方式,一般分为静态库和动态库.静态库与动态库的区别? 静态库:链接时完整地拷贝至可执行文件中,被多次使⽤用就为什 ...

  4. CALayer---iOS-Apple苹果官方文档翻译之CALayer

    CHENYILONG Blog CALayer---iOS-Apple苹果官方文档翻译之CALayer CALayer /*技术博客http://www.cnblogs.com/ChenYilong/ ...

  5. UIWebView---iOS-Apple苹果官方文档翻译

    CHENYILONG Blog UIWebView---iOS-Apple苹果官方文档翻译 UIWebView 技术博客http://www.cnblogs.com/ChenYilong/ 新浪微博h ...

  6. IOS开发苹果官方Sample Code及下载地址

    IOS开发苹果官方Sample Code及下载地址 在线浏览地址:https://developer.apple.com/library/ios/navigation/#section=Resourc ...

  7. NSURLSession---iOS-Apple苹果官方文档翻译

    CHENYILONG Blog NSURLSession---iOS-Apple苹果官方文档翻译 NSURLSession 技术博客http://www.cnblogs.com/ChenYilong/ ...

  8. iOS程序启动原理---iOS-Apple苹果官方文档翻译

    本系列所有开发文档翻译链接地址:iOS7开发-Apple苹果iPhone开发Xcode官方文档翻译PDF下载地址 //转载请注明出处--本文永久链接:http://www.cnblogs.com/Ch ...

  9. 基本控件文档-UITextField属性---iOS-Apple苹果官方文档翻译

    本系列所有开发文档翻译链接地址:iOS7开发-Apple苹果iPhone开发Xcode官方文档翻译PDF下载地址 //转载请注明出处--本文永久链接:http://www.cnblogs.com/Ch ...

随机推荐

  1. [codecademy]html&css

    1. HTML is the language used to create the web pages you visit everyday. It provides a logical way t ...

  2. 导弹拦截与Dilworth定理

    这两天被Dilworth.链和反链搞到头昏脑胀,终于有点眉目,现在来总结一下. Dilworth定理说的是:对于一个偏序集,其最少链划分数等于其最长反链的长度. Dilworth定理的对偶定理说的是: ...

  3. 浏览器中event.srcElement和event.target的兼容性问题

    在IE下,event对象有srcElement属性,但是没有target属性:Firefox下,even对象有target属性,但是没有srcElement属性.. 解决方法:使用obj(obj = ...

  4. spring ioc经典总结

    component-scan标签默认情况下自动扫描指定路径下的包(含所有子包),将带有 @Component @Repository @Service @Controller标签的类自动注册到spri ...

  5. django 使用json.dumps转换queryset的datatime报错问题解决

    最近在使用django做项目的时候想使用ajax来实现前后台数据的交互,但是在将数据库查询结果转换成json数据时,遇到时间格式的数据转换遇到问题,无法正确的进行转换,具体如下: 转换成json时使用 ...

  6. Win10修改编辑hosts文件无法保存怎么办

    Win10无法修改编辑保存hosts文件怎么办?Win10系统默认是没有权限去编辑保存系统里的文件,这也是权限不够才导致修改编辑hosts后无法保存的原因,解决的办法就是把自己的帐户权限给提高就行了. ...

  7. C#的垃圾回收

    C#中垃圾回收 GC.Collect();强制进行内存回收.

  8. string字符串比较和替换

    我用的是小写的string!! #include <string> #include <iostream> using namespace std; int main() { ...

  9. [剑指Offer] 58.对称的二叉树

    题目描述 请实现一个函数,用来判断一颗二叉树是不是对称的.注意,如果一个二叉树同此二叉树的镜像是同样的,定义其为对称的. [思路]递归,关键是isSame函数中的最后一句 /* struct Tree ...

  10. jQuery的动画与特效

    显示与隐藏 show() 和 hide() 方法 动画效果的show() 和 hide() show(speed,[]callback) hide(speed,[]callback) speed:表示 ...