UIPickerView 默认值为 Null [英] UIPickerView Default Value is Null
本文介绍了UIPickerView 默认值为 Null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是 UIPickerView
,它默认选择第一个值.然而,当用户没有从这个初始选择中移动 UIPickerView
时,选择的值作为 NSNull
返回.我怎样才能做到这一点:
I'm using a UIPickerView
, and it has the first value chosen by default. When the user doesn't move the UIPickerView
from this initial selection, however, the value selected comes back as NSNull
. How can I make it so either:
- 无论用户是否更改选择,都会识别第一个值.
UIPickerView
包含一个我可以在第一个位置检查的空白值.
- The first value is recognized whether the user changes the selection or not.
- The
UIPickerView
contains a blank value that I can check for in the first spot.
推荐答案
您可以使用
[_picker selectedRowInComponent:0]
nil
表示没有人移动选择器(您可以将第一项设为空白或诸如--"之类的)
nil
means no one move the picker (you can make the first item blank or sth like "--" )
参考:https://stackoverflow.com/a/27058363/471840
这篇关于UIPickerView 默认值为 Null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文