1

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)

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?

luk2302
  • 55,258
  • 23
  • 97
  • 137
Kevin Wu
  • 1,357
  • 1
  • 15
  • 34

1 Answers1

3

Try this:

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


override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {
    if segue.identifier == "showGeneralInformation" {
    }
}
Ashish Jaiswal
  • 804
  • 1
  • 9
  • 23
Sujay
  • 2,510
  • 2
  • 27
  • 47