首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用material.io时通过段链接按钮

使用material.io时通过段链接按钮
EN

Stack Overflow用户
提问于 2019-06-10 05:30:39
回答 1查看 167关注 0票数 0

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

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

我习惯于手动创建段,然后使用

代码语言:javascript
运行
复制
performSegue(withIdentifier: <#T##String#>, sender: <#T##Any?#>)

使用segue,但现在,因为我看不到按钮,我不能使用segue点击2个按钮登录和注册。

此外,通常在main.storyboard中,您可以使用IBOutlet或IBAction块来触发某些功能,例如单击按钮即可执行某些操作。例如,当您使用MDCButton时,这是如何工作的。如何将按钮链接到某个操作,如触发分段或更新文本字段。谢谢。

我像这样声明了我的按钮

代码语言:javascript
运行
复制
 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
    }()

我这样叫它

代码语言:javascript
运行
复制
 @objc func didTapNext(sender: Any) {
        self.performSegue(withIdentifier: "toRegistration", sender: self)
        self.dismiss(animated: true, completion: nil)
    }

我有一个连接两个视图控制器的段。

EN

回答 1

Stack Overflow用户

发布于 2019-06-10 11:51:31

我看不到你的代码,也没有足够的代表来评论,但看起来你正在以编程的方式构建你的视图。要查看按钮何时从插座接收touchUp,您需要添加一个目标。尝试如下所示:

代码语言:javascript
运行
复制
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)
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56518505

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档