【发布时间】:2019-02-27 06:10:52
【问题描述】:
对于 iOS 应用,我有一个带有 UITextView 的 UIViewController,它使用 inputAccessoryView 将视图保持在屏幕底部(或键盘顶部)。
但是,当我显示 UIAlertController 时,inputAccessoryView 消失了。
UIAlertController * view =[[UIAlertController alloc]init];
<Add menuItems>
[self presentViewController:view animated:YES completion:nil]; <-- inputAccessoryView disappears
我发现一些 stackOverFlow articles 解释了如何解决这个问题,但它们不仅在 Swift 中,而且甚至在 Objective-C 中翻译,它也不起作用:
UIViewController *objViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
[objViewController presentViewController:view animated:YES completion:nil];
如何保持我的输入 AccessoryView 显示?
【问题讨论】:
-
没关系,即使键盘关闭,我的 inputAccessoryView 也会显示。但是,即使显示 UIAlertController,我也希望 inputAccessoryView 保持不变。在我目前的情况下,当我关闭 UIAlertController 时 inputAccessoryView 会消失并重新出现。
-
即使我删除了 UITextView 的 First Responder,键盘也消失了,但 inputAccessoryView 仍然存在。某些应用程序(例如删除消息时的 WhatsApp)能够在显示 AlertViewController 时保留此 inputAccessoryView)
标签: ios objective-c uiviewcontroller inputaccessoryview