首页 文章

从纵向模式旋转到横向模式时,搜索栏丢失FirstResponder

提问于
浏览
1

我正在尝试模仿iPad Mail应用程序 . 在纵向模式下,当弹出框的搜索栏有第一个响应者并且我旋转到横向时,弹出窗口的搜索栏会丢失第一个响应者 . 我想继续以横向模式向搜索栏第一响应者提供纵向模式下的第一响应者 . 我怎样才能做到这一点?

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

轮换后:http://postimg.org/image/al7fh9snl/请注意,搜索栏会撤消第一个响应者 .

谢谢!

1 回答

  • 0

    在处理视图的roation的方法内部

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
    

    检查您所在的界面

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    
        if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
             [searchBar becomeFirstResponder];
        }
    }
    

    希望有所帮助!

相关问题