0317-iOS之UIPickerView类

Class

UIPickerView

A view that uses a spinning-wheel or slot-machine metaphor to show one or more sets of values.

    --使用类似 旋转轮或老虎机的样式 来显示一组或多组值的视图。

 

Declaration

class UIPickerView : UIView

Overview

A picker view displays one or more wheels that the user manipulates to select items. Each wheel—known as a component—has a series of indexed rows representing the selectable items. Each row displays a string or view so that the user can identify the item on that row. Users select items by rotating the wheels to the desired values, which align with a selection indicator.

       --选择器视图显示用户操作以选择项的一个或多个轮子。每个称为组件的“转轮”有一系列索引行,表示可选择的项。每行显示一个字符串或视图,以便用户可以识别该行上的项。用户通过将轮子旋转到所需的来选择项,这些值与选择中的项对齐

Note

The UIDatePicker class uses a custom subclass of UIPickerView to display dates and times. To see an example, tap the add (“+”) button in the Alarm pane of the Clock app.

     --UIDatePicker类使用UIPickerView的自定义子类来显示日期和时间。要查看示例,请单击“闹钟”应用程序的“闹钟”窗格中的“添加(+)”按钮。

You provide the data to be displayed in your picker view using a picker data source—an object that adopts the UIPickerViewDataSource protocol. Use your picker view delegate—an object that adopts the UIPickerViewDelegate protocol—to provide views for displaying your data and responding to user selections.

      --你提供的数据通过picker视图中使用的picker数据源显示,这是一个遵循了UIPickerViewDataSource协议的对象。使用picker视图委托对象来提供显示你的数据和响应用户选择的视图,委托对象遵循了UIPickerViewDelegate协议

 

Topics        --专题

Providing the Picker Data             --提供数据源

var dataSource: UIPickerViewDataSource?

The data source for the picker view.

 

protocol UIPickerViewDataSource

The UIPickerViewDataSource protocol must be adopted by an object that mediates between a UIPickerView object and your application’s data model for that picker view. The data source provides the picker view with the number of components, and the number of rows in each component, for displaying the picker view data. Both methods in this protocol are required.

 

Customizing the Picker Behavior              --自定义选择器的行为

var delegate: UIPickerViewDelegate?

The delegate for the picker view.

protocol UIPickerViewDelegate

The delegate of a UIPickerView object must adopt this protocol and implement at least some of its methods to provide the picker view with the data it needs to construct itself.

 

Getting the Dimensions of the View Picker             --获取选择器的维度

var numberOfComponents: Int

Gets the number of components for the picker view.

func numberOfRows(inComponent: Int) -> Int

Returns the number of rows for a component.

func rowSize(forComponent: Int) -> CGSize

Returns the size of a row for a component.

 

Reloading the View Picker               --重新加载选择器

func reloadAllComponents()

Reloads all components of the picker view.

func reloadComponent(Int)

Reloads a particular component of the picker view.

 

Selecting Rows in the View Picker            --在选择器中选中某行

func selectRow(Int, inComponent: Int, animated: Bool)

Selects a row in a specified component of the picker view.

func selectedRow(inComponent: Int) -> Int

Returns the index of the selected row in a given component.

 

Returning the View for a Row and Component            --获取指定行的view

func view(forRow: Int, forComponent: Int) -> UIView?

Returns the view used by the picker view for a given row and component.

 

Managing the Appearance of the Picker View             --管理选择器额外观,丢弃

通过delegates来设置每一个row的外观吧

var showsSelectionIndicator: Bool

A Boolean value that determines whether the selection indicator is displayed.

Deprecated

 

Relationships   --继承关系

Inherits From

UIView

Conforms To

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值