zoukankan      html  css  js  c++  java
  • UIPickView的基本使用

    UIPickView和TableView一样,想要展示数据也要设置数据源和代理
    设置数据源
    self.pickView.dataSource = self;
    设置代理
    self.pickView.delegate = self;


    遵守数据源,代理协议:
    @interface ViewController ()
    <UIPickerViewDataSource,UIPickerViewDelegate>
    @property (weak, nonatomic) IBOutlet UIPickerView *pickView;
    @end


    实现数据源代理方法:
    总共有多少列
    - (NSInteger)numberOfComponentsInPickerView:(UIPickerView*)pickerView{

      return 3;
    }


    第component列有多少行.
    - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{

      return 4;
    }


    返回每一列的宽度
    - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component{

    }


    返回第一列的高度
    - (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component{

      return 50;
    }


    返回每一行的标题
    - (nullable NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{

      return @"gaowei";
    }


    返回每一行的视图UIView
    - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(nullable UIView *)view{

      UIButton *btn = [UIButton
      buttonWithType:UIButtonTypeContactAdd];
      return btn;
    }

  • 相关阅读:
    ajax基本使用
    ajax
    七个你无法忽视的Git使用技巧
    Git原始笔记
    php session自定义处理
    linux下用phpize给PHP动态添加扩展
    【转】做到这一点,你也可以成为优秀的程序员
    PHP扩展开发-测验成功
    PHP扩展开发--实验成功
    php类似shell脚本的用法
  • 原文地址:https://www.cnblogs.com/xufengyuan/p/6920775.html
Copyright © 2011-2022 走看看