Swift:如何在 Swift 中使用三个组件设置 UIPickerView 的默认值? [英] Swift: How to set a default Value of a UIPickerView with three components in Swift?

查看:46
本文介绍了Swift:如何在 Swift 中使用三个组件设置 UIPickerView 的默认值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Swift 中设置选择器视图的起始行?我看到有一个 Objective C 的代码,但我不明白.如果有人能解释我如何将 Objective C 代码翻译成 Swift,那也太棒了!

How do I set the starting row of the picker view in Swift? I see there is a code for Objective C, but I don't understand it. If anyone could explain how I can translate the Objective C code into Swift that would also be fantastic !

谢谢

推荐答案

这是我在我的一个应用程序中使用的代码:

This is the code I have used in one of my apps:

// Declare the outlet to the picker in your storyboard
@IBOutlet var myPicker: UIPickerView!

//...

override func viewDidLoad() {
//...
    myPicker.selectRow(row, inComponent: 0, animated: true)
}

显然,将 row0 替换为您想要的任何值.

Obviously, replace row and 0 with whatever values you want.

希望这有帮助!

这篇关于Swift:如何在 Swift 中使用三个组件设置 UIPickerView 的默认值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆