I have a UIButton
in a prototype UItableviewcell
that is made in a nib.
The UITableView is inside a UIViewController.
The requirement is: When I press the UIButton
, a segue should be performed from Main UIViewController
to another second UIViewController
. I can access the UIButton IBOutlet from the table , so is there any way to call a function through that UIButton Variable.
// for reference
let x= cell.followButton;
Asked
Active
Viewed 64 times
0

Talha Ahmad Khan
- 3,416
- 5
- 23
- 38
-
1Have you check the docs for UIButton? What you are looking for is shown in there. – Fogmeister May 10 '16 at 13:15
-
There are plenty of answer for this question in stackOverFlow: http://stackoverflow.com/q/24102191/2695909 – Altimir Antonov May 10 '16 at 14:16
1 Answers
0
Add a target to the button to call a method in your view controller. In this code, self
is your view controller.
cell.followButton.addTarget(self, action: #selector(buttonPressed), forControlEvents: .TouchUpInside)
Then implement buttonPressed
to handle segueing.
func buttonPressed() {
performSegueWithIdentifier("Identifier", sender: self)
}

keithbhunter
- 12,258
- 4
- 33
- 58