2016-01-20 40 views
1

我已閱讀並在此處搜索以獲取答案,並且有人說在iOS 9中,您不需要在iPad上彈出額外的代碼,我也有嘗試了其他兩個相關問題中的代碼,但它不能正常工作彈出窗口只顯示刪除和不取消。它工作正常在iPhone和iPhone plus.Here是我的代碼:在iPad上測試時因應用程序彈出而導致應用程序崩潰

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) 

    } 
} 
+1

如果崩潰,應該在日誌中的錯誤/崩潰的消息。它說什麼? – Larme

+1

「它無法正常工作」它只是不起作用或它會崩潰嗎?如果它崩潰,請顯示錯誤消息。 – Moritz

+0

請參閱如何提問:http://stackoverflow.com/help/how-to-ask –

回答