我已经覆盖了 UIViewController 中的 -inputAccessoryView:
方法,该方法返回一个显示在键盘顶部的 View ,该 View 在编辑 viewController 上的 UITextField
时显示查看。
-(UIView *)inputAccessoryView;
我还从 viewController 中呈现了一个 UIAlertController。
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Save Profile" message:@"You have made changes to your profile. Do you want to save them?" preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
[alert addAction:[UIAlertAction actionWithTitle:@"Save" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
//Code to save the profile.
}]];
[self presentViewController:alert animated:YES completion:nil];
如您所见,我没有向 UIAlertController 添加任何文本字段。
奇怪的是,当 UIAlertController 出现时,inputAcessoryView 出现在屏幕底部。
这是一个错误,还是我忽略了什么?
最佳答案
将您的输入附件 View 重命名为 inputAccessoryView
以外的名称。
例如keyboardaccessoryView.
然后添加下面一行
self.m_textFieldName.inputAccessoryView = [self keyboardInputAccessoryView];
这解决了我的问题。
关于ios - inputAccessoryView 与 UIAlertController 一起显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31590640/