iosswiftuitableviewsegueuitableviewrowaction

Swipe to edit details using Segue


I'm new to IOS development and swift so I'm a bit confused. Building on this question

Swipe To Edit Details Swift and Parse

I have a table cell that I swipe and when I click edit, I want it to go to another page to edit the details. When i don't have a segue, it asks for one as an error. When I put one (going from prototype cell > edit page), it works, except now it goes there when I click on the cell in addition to swipe.

I just want it to Edit only on swipe. How would one do that?


Solution

  • ViewController A: where you have the cell ViewController B: the viewController what you would like to present.

    On the storyboard, click on viewController A, press and hold CTRL, and drag the blue line to ViewController B. Choose "show" segue.

    enter image description here

    Click on the segue, and lets name it "EditDetails"

    enter image description here

    Now you got the segue set up. After this, you should call:

    self.performSegueWithIdentifier("EditDetails", sender: self)
    

    instead of calling this

    self.performSegueWithIdentifier("EditDetails", sender: tableView.cellForRowAtIndexPath(indexPath))
    

    Reason: it is the viewController, which will perform the segue, not the tableViewCell.