我是swift的初学者,我正在使用Swift中的Material.io创建登录屏幕,我的UI如下所示

。但是,我的main.storyboard上看不到任何东西

我习惯于手动创建段,然后使用
performSegue(withIdentifier: <#T##String#>, sender: <#T##Any?#>)使用segue,但现在,因为我看不到按钮,我不能使用segue点击2个按钮登录和注册。
此外,通常在main.storyboard中,您可以使用IBOutlet或IBAction块来触发某些功能,例如单击按钮即可执行某些操作。例如,当您使用MDCButton时,这是如何工作的。如何将按钮链接到某个操作,如触发分段或更新文本字段。谢谢。
我像这样声明了我的按钮
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)
}
我有一个连接两个视图控制器的段。
发布于 2019-06-10 11:51:31
我看不到你的代码,也没有足够的代表来评论,但看起来你正在以编程的方式构建你的视图。要查看按钮何时从插座接收touchUp,您需要添加一个目标。尝试如下所示:
func functionWhereYouCreateTheButton() { (PROBABLY YOUR VIEW DID LOAD)
let loginButton = UIButton()...
...
...
...
loginButton.addTarget(self, action: #selector(self.buttonTapped), for: .touchUpInside)
}
func buttonTapped() {
self.performSegue(withIdentifier: "SEGUEID", sender: self)
}https://stackoverflow.com/questions/56518505
复制相似问题