【问题标题】:Modal view shifting when UISearchBar becomes first responder in landscape orientation当 UISearchBar 成为横向的第一响应者时,模态视图移动
【发布时间】:2014-03-05 21:34:48
【问题描述】:

在我的应用程序中,我正在显示带有搜索栏的模式视图。我在模态视图控制器的 viewDidAppear 中设置了 becomeFirstResponder。这在纵向视图中运行良好,模态视图和键盘从底部弹出。

当我以横向方式执行此操作时,模态视图显示正常,但当显示键盘时,视图会根据 iPad 顶部的朝向向左或向右移动。模态视图似乎认为它仍然是纵向的。我该如何解决这个问题?

【问题讨论】:

  • 我也遇到了这个问题。你有想过解决办法吗?

标签: ios ipad cocoa-touch


【解决方案1】:

我不太确定这个问题的根源是什么,但我通过将 modalPresentationStyle 设置为 UIModalPresentationPageSheet 而不是 UIModalPresentationFormSheet 解决了这个问题。

myVC.modalPresentationStyle = UIModalPresentationPageSheet;

【讨论】:

  • 这并没有解决我的问题。
  • 这解决了这个问题,但模态视图最终以更大的框架结束。如果您想保留 UIModalPresentationFormSheet 样式框架,这将不起作用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-02
  • 2018-02-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多