为什么从搜索栏中退出键盘后为什么还会留下UIToolbar?

问题描述 投票:0回答:1

这是通过编程方式进行的。我在导航标题视图中添加了UISearchBar。当控制器首次加载时,它将成为第一响应者。单击搜索栏上的“取消”按钮可删除键盘,并返回到根视图控制器。发生这种情况时,会在整个UIToolBar视图的顶部留下一个UIToolbar,并出现明显的模糊。我已经通过“视图层次结构”对其进行了检查,并显示了它是工具栏,在我认为键盘底视图中是表情符号按钮和语音按钮所在的位置。我尝试了resigningFirstResponder和endEditing(true)。两者仍然都留在了我从未在应用程序中创建的工具栏的后面。关于如何修复它的任何建议,还是我无法控制的错误?

实施,

// Setup for viewDidLoad
    private func setup() {
        // Navigation
        navigationController?.setToolbarHidden(false, animated: true)
        navigationItem.setHidesBackButton(true, animated: false)
        searchView.searchBar.delegate = self
        navigationItem.titleView = searchView.searchBar
        searchView.searchBar.becomeFirstResponder()
    }

    // When the cancel button is pressed
    public func goBackToRootController() {
        // I've used both individually and together and the problem still occurs
        searchView.searchBar.resignFirstResponder()
        searchView.searchBar.endEditing(true)
        navigationController?.popToRootViewController(animated: true)
    }

ios swift uisearchbar uikeyboard programmatically-created
1个回答
0
投票

问题已修复-setToolBarHidden()方法设置为false。在整个应用程序中启用或显示工具栏。

© www.soinside.com 2019 - 2024. All rights reserved.