【发布时间】:2019-10-24 09:19:43
【问题描述】:
我是 Swift 的初学者,我正在使用 Swift 中的 Material.io 创建一个登录屏幕,我的 UI 看起来像这样 。 但是我在我的 main.storyboard 上没有看到任何东西 我习惯于手动创建一个 segue 然后使用
performSegue(withIdentifier: <#T##String#>, sender: <#T##Any?#>)
此外,通常在 main.storyboard 中,您有一个 IBOutlet 或 IBAction 块来触发某些功能,例如在单击按钮时执行某些操作。 例如,当您使用 MDCButton 时,它是如何工作的。如何将按钮链接到触发 segue 或更新文本字段等操作。 谢谢。
我已经这样声明了我的按钮
let nextButton: MDCButton = {
let nextButton = MDCButton()
let containerScheme = MDCContainerScheme()
nextButton.applyTextTheme(withScheme: containerScheme)
nextButton.setTitleColor(.white, for: .normal)
nextButton.translatesAutoresizingMaskIntoConstraints = false
nextButton.setTitle("CREATE NEW ACCOUNT", for: .normal)
nextButton.addTarget(self, action: #selector(didTapNext(sender:)), for: .touchUpInside)
return nextButton
}()
我这样称呼它
@objc func didTapNext(sender: Any) {
self.performSegue(withIdentifier: "toRegistration", sender: self)
self.dismiss(animated: true, completion: nil)
}
我有一个连接 2 个视图控制器的 segue。
【问题讨论】:
标签: ios swift material-design material-components material-components-ios