ios - 当 UIAlertController 显示时 inputAccessoryView 被关闭
问题描述
对于 iOS 应用程序,我有一个带有 UITextView 的 UIViewController,它使用 inputAccessoryView 将视图保持在屏幕底部(或键盘顶部)。
但是,当我显示 UIAlertController 时,inputAccessoryView 消失了。
UIAlertController * view =[[UIAlertController alloc]init];
<Add menuItems>
[self presentViewController:view animated:YES completion:nil]; <-- inputAccessoryView disappears
我找到了一些解释如何解决此问题的 stackOverFlow文章,但它们不仅在 Swift 中,而且甚至在 Objective-C 中翻译,它也不起作用:
UIViewController *objViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
[objViewController presentViewController:view animated:YES completion:nil];
如何保持我的输入 AccessoryView 显示?
解决方案
通过正确翻译引用文章中指示的 Swift 答案找到它:
UIViewController *objViewController = [UIApplication sharedApplication].windows.lastObject.rootViewController;
[objViewController presentViewController:view animated:YES completion:nil];
推荐阅读
- automation - 编码的 ui 对象存储库
- mysql - 表被锁定在 MySQL 数据库中
- mongodb - Mongodb 3.4.7 分组后一个字段的聚合不同计数
- c# - C# 检查 PropertyInfo 的类型是否是原始的
- android - ExoPlayer ConcatenatingMediaSource ArrayIndexOutOfBoundsException
- matlab - 如何在matlab中对结构数组求和?
- magento - 我在 magento 2 的前端创建了一个自定义菜单
- html - 转到 chrome 移动设备视图时出现奇怪的 css/html 间隙
- ios - ARKit Ball Pass through Torus 孔碰撞检测
- kubernetes - 错误:服务器没有资源类型“svc”