Кажется, что вызов Alert в моем UIViewController вызывает ploblems с помощью currentViewController (... из-за того, что, возможно, непреднамеренно пытается представить один и тот же контроллер представления дважды в быстрой последовательности ...).Предупреждение не работает из-за presentViewController
Что я могу сделать против этой проблемы (... см. Код ниже) ???
Сообщение об ошибке:
<MyApp.MyViewController: 0x67544325620> which is already presenting (null)
Код:
func textFieldShouldEndEditing(textField: UITextField) -> Bool {
if (textField.text.lengthOfBytesUsingEncoding(NSUTF8StringEncoding) > 5) {
var alert = UIAlertController(title: "Warning", message: "Only Initials with maximal 5 letters allowed!", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
// that is where the problem seems to occur.... !!! Why ????
self.presentViewController(alert, animated: true, completion: nil)
return false
}
return true
}
"не работает" - в каком смысле? что происходит и что должно произойти? – luk2302