Charlie
Charlie

Reputation: 33

How to trigger a UIViewController segue based on gesture actions in a UItableViewCell using Xcode

I am prototyping an iOS app, using Xcode and swift language, that uses different gesture actions in a given UITableViewCell to initiate a particular segue to another UIViewController.

The UI is modeled after the mail app where a pan gesture recognizer is added to a UITableViewCell view. Depending on if the UITableViewCell view is panned left or right or how far it is panned before released should determine which 1 of several view controllers is segued to.

I have successfully set up the pan gesture recognizer in the UITableViewCell to my satisfaction by switching on the translationInView and the action and animations work great.

What I was planning to do on each switch condition is add a performSegueWithIdentifier to trigger 1 of the 4 different segues, but apparently this does not work from within a UITableViewCell.

link to github files

Any help is GREATLY appreciated! :D Charlie

Upvotes: 0

Views: 385

Answers (1)

dopcn
dopcn

Reputation: 4218

You can't performSegueWithIdentifier within a UITableViewCell because it's viewController's method.

So

  1. define your custom tableViewCell protocol
  2. make your viewController conform to it then
  3. when you need perform a segue delegate the need to viewController

Upvotes: 1

Related Questions