iOS 11搜索栏跳到屏幕顶部 [英] iOS 11 search bar jumping to top of screen

查看:132
本文介绍了iOS 11搜索栏跳到屏幕顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UITableView,我将其标题设置为搜索栏。

I've got a UITableView in which I set its header to be a search bar.

tableView.tableHeaderView = searchController.searchBar

一切都按计划运行,直到你点击它,它似乎与tableView分离并跳转到屏幕的顶部。 tableView行保持不变。有什么理由在iOS 11而不是iOS 10中这样做吗?

Everything works according to plan until you click it and it seemingly detaches from the tableView and jumps to the top of the screen. The tableView rows stay in place. Any reason it would do that in iOS 11 and not iOS 10?

推荐答案

鼓励应用新的方式来显示搜索iOS 11上的吧/搜索控制器。
以下是我所做的:

It is encouraged to apply the new way to show search bar/search controller on iOS 11. Here is what I have done:

    if #available(iOS 11.0, *) {
        navigationItem.searchController = searchController
    } else {
        tableView.tableHeaderView = searchController.searchBar
    }

这篇关于iOS 11搜索栏跳到屏幕顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆