滚动表格视图后未返回到底部,以编程方式与searchViewController一起使用

时间:2018-12-11 11:20:55

标签: uitableview scrollview uisearchcontroller

我使用了表格视图来显示数据,但是当我向上滚动表格视图时却遇到问题,但它仍然停留在底部。我正在分享屏幕截图。 tableview scroll issue

在tableview的内部标头中,当我删除searchview controller tableview时,我已经使用了搜索控制器,但是使用searchview controller仍然没有问题。

 self.searchController = ({
            let controller = UISearchController(searchResultsController: nil)
            controller.searchResultsUpdater = self
            controller.dimsBackgroundDuringPresentation = false
            searchController.hidesNavigationBarDuringPresentation = false
            controller.searchBar.sizeToFit()
            controller.searchBar.placeholder = "Search by Receipt No, Order No"

            controller.searchBar.showsCancelButton = false
            controller.searchBar.backgroundColor = #colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
            controller.searchBar.searchBarStyle = .minimal

            controller.searchBar.setShowsCancelButton(false, animated: false)

            let textFieldInsideSearchBar = controller.searchBar.value(forKey: "searchField") as? UITextField

            let imageView = textFieldInsideSearchBar?.leftView as! UIImageView
            imageView.image = imageView.image?.withRenderingMode(UIImageRenderingMode.alwaysTemplate)
            imageView.tintColor = #colorLiteral(red: 0.8901960784, green: 0.1764705882, blue: 0.2156862745, alpha: 1)

            let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(imageTapped(tapGestureRecognizer:)))
            imageView.isUserInteractionEnabled = true
            imageView.addGestureRecognizer(tapGestureRecognizer)

            let placeholderLabel = textFieldInsideSearchBar?.value(forKey: "placeholderLabel") as? UILabel
            placeholderLabel?.font = UIFont.systemFont(ofSize: 14)

            //Add searchbar controller in header
            self.tableView.tableHeaderView = controller.searchBar

            return controller
        })()

0 个答案:

没有答案