I have read and searched here for an answer and some people say that in iOS 9 you don't need extra code for a pop-over on an iPad, i have also tried the code in the other two related questions but it doesn't work correctly the pop-over shows only delete and not cancel. It works fine on iPhone and iPhone plus.Here is my code:
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == .Delete {
let item = itemStore.allItems[indexPath.row]
let title = "Delete \(item.name)?"
let message = "Are you sure you want to delete this item"
let ac = UIAlertController(title: title, message: message, preferredStyle: .ActionSheet)
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil)
ac.addAction(cancelAction)
let deleteAction = UIAlertAction(title: "Delete", style: .Destructive, handler: { (action) -> Void in
self.itemStore.removeItem(item)
self.tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
})
ac.addAction(deleteAction)
presentViewController(ac, animated: true, completion: nil)
}
}