0

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;

Talha Ahmad Khan
  • 3,186
  • 5
  • 20
  • 37

1 Answers1

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,080
  • 4
  • 36
  • 58