【问题标题】:Search Bar Loses FirstResponder when rotated from Portrait to Landscape mode从纵向模式旋转到横向模式时,搜索栏会丢失 FirstResponder
【发布时间】:2013-07-20 23:41:21
【问题描述】:

我正在尝试模仿 iPad 邮件应用程序。在纵向模式下,当弹出框的搜索栏有第一响应者并且我旋转到横向时,弹出框的搜索栏会失去第一响应者。当第一响应者处于纵向模式时,我想继续在横向模式下为搜索栏提供第一响应者。我该怎么做?

人像模式: http://postimg.org/image/kwjs9xkcx/

旋转后: http://postimg.org/image/al7fh9snl/ 请注意,搜索栏退出了第一响应者。

谢谢!

【问题讨论】:

标签: ios uilabel uisplitviewcontroller autolayout


【解决方案1】:

在处理视图旋转的方法中

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;

查看你所在的界面

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
         [searchBar becomeFirstResponder];
    }
}

希望有帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-11
    • 1970-01-01
    相关资源
    最近更新 更多