使用 UIButton 在视图之间导航 [英] Using UIButton to navigate between views

查看:18
本文介绍了使用 UIButton 在视图之间导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我以编程方式将 UIButton 添加到我的视图中,但我无法让它们做任何事情.如果按下,他们不会带我到下一个视图,这是他们应该做的.这是代码(抱歉格式不正确):

So I programmatically added UIButtons to my views, but I can't make them do anything. If pressed, they don't take me to the next view, which they are supposed to do. Here is the code (sorry for the bad formatting):

let buttonMen   = UIButton.buttonWithType(UIButtonType.System) as! UIButton
buttonMen.frame = CGRectMake(213, 108, 162, 306)
buttonMen.addTarget(self, action: "btnTouched:", forControlEvents:.TouchUpInside)
self.view.addSubview(buttonMen)

我的下一个视图称为General Information Page",而两个视图之间的连接称为showGeneralInformation".那么我需要在上面的代码中添加什么,如果当我按下按钮时,它会将我从当前视图带到一般信息页面"视图?

My next view is called "General Information Page", while the connection between the two views is called "showGeneralInformation". So what do I need to add to the above code, if when I press the button, it takes me to the "General Information Page" view from my current view?

推荐答案

试试这个:

func btnTouched(sender:UIButton!) {
     self.performSegueWithIdentifier("showGeneralInformation", sender: self)
}


override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {
    if segue.identifier == "showGeneralInformation" {
    }
}

这篇关于使用 UIButton 在视图之间导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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