Каждая ячейка в моем представлении коллекции имеет кнопку и текстовое поле.Как представить UIAlertController с точки зрения?
Когда кнопка нажата, я хочу отобразить предупреждение, если текстовое поле пуст.
В моей настраиваемое представление коллекции ячейки у меня есть:
func displayAlert(title: String, error: String) {
var alert = UIAlertController(title: title, message: error, preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: { action in
alert.dismissViewControllerAnimated(true, completion: nil)
}))
self.presentViewController(alert, animated: true, completion: nil)
}
func redeemButtonPressed(sender: UIButton!) {
if enterCodeTextField.text == "" {
displayAlert("Something went wrong", error: "Please enter a valid code")
}