搜索栏取消按钮仅在iPad上不可见

塔尔沃·梅塞普(TarvoMäesepp)

首先,我想说的是,在中找不到任何好的答案Swift我创造了search bar在按钮上单击会显示,在取消上会隐藏searchbar它工作正常,取消按钮是可见的所有iPhones,但由于某种原因不能iPad是什么原因造成的?

这就是我创建的方式searchbar

//Create searchbar
    func createSearchBar(){

        searchBar.showsCancelButton = true
        searchBar.tintColor = UIColor(red:0.184, green:0.996, blue:0.855, alpha:1.00)
        searchBar.placeholder = "Search brands"
        searchBar.delegate = self



        searchBar.hidden =  false
        searchBar.alpha = 0

        navigationItem.titleView = searchBar
        navigationItem.setLeftBarButtonItem(menuButton, animated: true)
        navigationItem.setRightBarButtonItem(searchButtton, animated: true)


        UIView.animateWithDuration(0.5, animations: {
            self.searchBar.alpha = 1
            }, completion: { finished in
                self.searchBar.becomeFirstResponder()
        })


    }
查图兰加席尔瓦

面对我的同一项目。我已经在Apple论坛上发布了文章,很多开发人员都将其评论为xcode错误。所以我为iPad视图手动添加了取消按钮

 func configureCancelBarButton() {
    let cancelButton = UIBarButtonItem()
    cancelButton.image = UIImage(named: "cancelButton")
    cancelButton.action = #selector(viewController.ipadCancelButton(_:))
    cancelButton.target = self
    self.navigationItem.setRightBarButtonItem(cancelButton, animated: true)
}

我之前曾发布过有关此问题的答案。也检查一下:)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章