Поэтому я использую UIAlertController со стилем листа действий для отображения двух параметров: один для отмены действия, а другой для удаления данных. Кнопки работают нормально, кнопка удаления работает, а лист действий закрывается. Моя проблема в том, что само представление не закрывается после удаления данных из облака в фоновом режиме. Почему вид не сбрасывает сам себя?
@IBAction func deleteRecipePressed() {
// Create the alert controller
let actionSheetController: UIAlertController = UIAlertController(title: "Delete Recipe?", message: "Are you positive you want to delete this recipe? This action can not be undone!", preferredStyle: .ActionSheet)
// Create and add the cancel action
let cancelAction: UIAlertAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: {action -> Void in
// Just dismiss the action sheet
})
actionSheetController.addAction(cancelAction)
// Create and add the delete action
let deleteAction: UIAlertAction = UIAlertAction(title: "Delete", style: .Default, handler: {action -> Void in
// Set deleteRecipe to true to flag for deletion
self.deleteRecipe = true
})
actionSheetController.addAction(deleteAction)
// Present the alert
self.presentViewController(actionSheetController, animated: true, completion: nil)
// If flagged for deletion, delete the recipe and dismiss the view
if (deleteRecipe == true) {
recipeObject.deleteInBackground()
self.dismissViewControllerAnimated(true, completion: nil)
}
}