• iOS-UIPickerView


     6.16 UIPickerView

    6.16.1 UIPickerViewDataSource
             // 返回列数
    - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;
    //返回每列的行数

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

    6.16.2 UIPickerViewDelegate

    // 返回数据

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

    // 返回列宽度

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

    //返回行高度

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

     

     

    组件_UIPickerView

    <UIPickerViewDataSource, UIPickerViewDelegate>

     - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView //有几列

    - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component //每一列行数

    [pickerView reloadComponent:1]; //刷新数据
    /第component列第row行显示什么字符串内容

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

    //每当选择一行就会调用

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

     / 第component列第row行显示什么样的UIView,用自定义视图填充选择器的内容,view参数是用来性能优化的
    - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view

    // 返回第component列每一行的高度

    - (CGFloat)pickerView:rowHeightForComponent:
    /手码自定义PickerView时,需要指定显示选择指示器属性
    [picker setShowsSelectionIndicator:YES];
    / 初始化Picker的选项
    [picker selectRow:8 inComponent:0 animated:YES];
  • 相关阅读:
    html-----vedio标签(HTML5新标签VIDEO在IOS上默认全屏播放)
    JS---控制键盘事件
    js事件监听-addEventListener (w3c标准) 和 attachEvent(ie)
    html5 -----audio标签
    花点时间搞清top、clientTop、scrollTop、offsetTop
    vue手机端横屏竖屏切换
    spring事务
    跨域
    java8 lambda 与 stream
    vueAdmin使用动态路由时踩坑
  • 原文地址:https://www.cnblogs.com/linxiu-0925/p/5058153.html
Copyright © 2020-2023  润新知