I have a UItableview
in which I have cells that shows post of the users.
I want users to have the ability to delete their post with a "delete button" that is showed in their post.
I can do it but I want users to have a confirmation pop-up first when they click the delete button in the cell.
So I am adding the code below as an action in the "cell" file of the table, but I get an error which say "use of unresolved identifier presentviewcontroller".
Can I not use the presentviewcontroller inside a cell file?
@IBAction func button_clicked(sender: AnyObject) {
var refreshAlert = UIAlertController(title: "Refresh", message: "Do you want to delete this post?", preferredStyle: UIAlertControllerStyle.Alert)
refreshAlert.addAction(UIAlertAction(title: "Yes", style: .Default, handler: { (action: UIAlertAction!) in
println("Handle Ok logic here")
}))
refreshAlert.addAction(UIAlertAction(title: "No", style: .Default, handler: { (action: UIAlertAction!) in
println("Handle Cancel Logic here")
}))
presentViewController(refreshAlert, self, completion: nil)
}
Hmm, better use alert control in the view controller, because in controller, u can get every thing like tableview (say after deleting comment u have to reload), the data to be delete (something which is present in the (for example)array that u are used to display in tableview)... etc
first define a delegate method in the
cell file
for examplein the
ViewController