Swift:将 searchBar 固定到 tableView 标题中 [英] Swift: fixed searchBar into tableView header

查看:22
本文介绍了Swift:将 searchBar 固定到 tableView 标题中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 tableView,表头中有一个 searchBar.

I have a tableView with a searchBar inside the table header.

一切都运行良好,除了当我向下滚动行时,搜索栏消失了.

Everything is working well except when I scroll down the rows, the search bar disappear.

如何修复?

推荐答案

没有办法保持 tableView 的 header 固定,但是当你需要一个唯一的 header 时,一个有用的方法是使用 UIViewController 而不是 UITableViewController, 并在 tableView 上方设置标题(包含 searchBar 的 UIView).

There is no a way to maintain the header of a tableView fixed, but an useful approach when you need a unique header, could be to use UIViewController instead of UITableViewController, and set the header (UIView that contains searchBar) above the tableView.

这篇关于Swift:将 searchBar 固定到 tableView 标题中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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