Я представил UIAlertController с текстовым полем, но всякий раз, когда я набираю текст, в текстовом поле ничего не появляется, и появляется предупреждение, как запрос caretRectForPosition: в то время как NSTextStorage имеет выдающиеся изменения {0, 0}.Мой код
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"title" message:@"message" preferredStyle: UIAlertControllerStyleAlert];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.keyboardType = UIKeyboardTypeNumberPad;
// textField.secureTextEntry = YES;
//textField.delegate = self;
}];
UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSArray * textfields = alertController.textFields;
UITextField * cardField = textfields[0];
NSLog(@"Current password %@", [cardField text]);
if ([cardField hasText]) {
//will do something
}
}];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"Canelled");
}];
[alertController addAction:confirmAction];
[alertController addAction:cancelAction];
[self presentViewController:alertController animated:YES completion:nil];
и ошибка requesting caretRectForPosition: while the NSTextStorage has oustanding changes {0, 0}