Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift,UISearchBar多个问题,同时单击_Swift_Uisearchbar - Fatal编程技术网

Swift,UISearchBar多个问题,同时单击

Swift,UISearchBar多个问题,同时单击,swift,uisearchbar,Swift,Uisearchbar,我有两个问题。当我点击搜索栏时,背景并没有覆盖顶部空间的适当视图。而取消按钮仅在我第一次点击搜索栏时出现。如果我再次点击,取消按钮将消失。 也已附加快照 下面是我的代码 在viewDidLoad中 self.contactsTableView.delegate = self self.contactsTableView.dataSource = self self.resultSearchController = ({ let controlle

我有两个问题。当我点击搜索栏时,背景并没有覆盖顶部空间的适当视图。而取消按钮仅在我第一次点击搜索栏时出现。如果我再次点击,取消按钮将消失。 也已附加快照

下面是我的代码

在viewDidLoad中

    self.contactsTableView.delegate = self
    self.contactsTableView.dataSource = self
    self.resultSearchController = ({

            let controller = UISearchController(searchResultsController: nil)
            controller.searchBar.barTintColor = UIColor.whiteColor()
            controller.searchResultsUpdater = self
            controller.searchBar.delegate = self
            controller.dimsBackgroundDuringPresentation = false
            controller.searchBar.sizeToFit()

            self.contactsTableView.tableHeaderView = controller.searchBar
            return controller
        })()

    self.contactsTableView.reloadData()


    func searchBarTextDidBeginEditing(searchBar: UISearchBar) {
        searchBar.frame = CGRectMake(0, 0, searchBar.frame.width, 44)
        searchBar.tintColor = UIColor.whiteColor()
        searchBar.backgroundColor = self.utility.uicolorFromHex(0x63003C)
        searchBar.barTintColor = self.utility.uicolorFromHex(0x63003C)

    }

func searchBarTextDidEndEditing(searchBar: UISearchBar) {
          searchBar.tintColor = UIColor.whiteColor()
    }

func searchBarCancelButtonClicked(searchBar: UISearchBar) {
          searchBar.tintColor = UIColor.whiteColor()
          searchBar.backgroundColor = UIColor.whiteColor()
          searchBar.barTintColor = UIColor.whiteColor()
    }
已按代码而不是情节提要包含UISearchBar控制器。
有人能帮我吗?

有人有解决办法吗?有人有解决办法吗?