美文网首页iOS学习iOS开发程序员
使用UISearchController becomeFirs

使用UISearchController becomeFirs

作者: Wang_dong | 来源:发表于2016-12-16 11:27 被阅读394次

    项目中有一个点击搜索按钮之后跳转到搜索页面的功能,需求是跳转到搜索页面之后键盘自动弹出,但是试了很多方法都不行...最后还是在老外的帮助下完美的解决了问题,老外还是给力的呀!我用的是swift写的代码,所以写OC的同学自己翻译一下~

    代码:

    override func viewDidAppear(_animated:Bool) {

    super.viewDidAppear(animated)

    self.perform(#selector(self.showKeyboard), with:nil, afterDelay:0.1)

    }

    func showKeyboard() {

    self.searchController.searchBar.becomeFirstResponder()

    }

    其实就是加了个0.1S的延时,完美解决~

    相关文章

      网友评论

        本文标题:使用UISearchController becomeFirs

        本文链接:https://www.haomeiwen.com/subject/bkdnmttx.html