1

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)

   }
}
Angel Caro
  • 93
  • 8

1 Answers1

0

This is caused by a change in iOS 8. You have to use UIModalPresentationPopover for the iPad.

Here's a detailed description in another stack overflow question: Presenting a UIAlertController properly on an iPad using iOS 8

Community
  • 1
  • 1
Stefan
  • 5,203
  • 8
  • 27
  • 51