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?
Am I supposed to suppress the default action of the segue in prepareForSegue
so that EditDetails
segue gets triggered only when I tell it to (like below)?
var editAction = UITableViewRowAction(style: .Default, title: "Edit" , handler: { (action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in
dispatch_async(dispatch_get_main_queue()) {
self.performSegueWithIdentifier("EditDetails", sender: tableView.cellForRowAtIndexPath(indexPath))
}
})
editAction.backgroundColor = UIColor.greenColor()
Am I supposed to create the segue in code instead of through the UI, so it doesn't add any additional actions that I don't need?
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.
Click on the segue, and lets name it "EditDetails"
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.