ios - inputAccessoryView 与 UIAlertController 一起显示

标签 ios objective-c uiviewcontroller uialertcontroller presentviewcontroller

我已经覆盖了 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/

相关文章:

ios - 返回事件在 swift 3.0 中的哪里

ios - UIView 似乎已锁定 - 这是一个奇怪的

iphone - 如何在iPhone上实现自动接听?

ios - 核心数据按年份分组并按日期排序

objective-c - SWIFT_EXEC 用户定义设置的 Objective-C 等价物是什么?

iphone - 基于全局变量的变化 View Controller

iphone - 有没有办法动态更改 View 以填充屏幕?

ios - 检查 SKCameraNode View 是否包含某个类的节点?

ios - 如何设置普通 UITableView 页眉和页脚的颜色并删除不必要的单独行?

ios - Swift 2.0 : Variable was never mutated, 考虑改成让