当SearchBar不返回结果时,在TableView顶部显示替代视图 [英] Display alternative View on top of a TableView when SearchBar is not returning results

查看:46
本文介绍了当SearchBar不返回结果时,在TableView顶部显示替代视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用中,我有一个由搜索栏填充的表格视图(我的意思是,搜索栏正在查询CoreData,而表格视图则由结果填充).

in my app I have a table view that is populated by a Search Bar (I mean, the search Bar is querying CoreData and the Table View is filled by the results).

现在,进入应用程序的这一部分时,我有一个空的表视图,等待用户在搜索栏中输入内容.

Right now, when entering this part of the app, I have an empty Table View waiting for the user to input something in the search bar.

我想要的是在表没有结果时显示替代视图.自昨天以来,我在Google上搜索了很多东西,而我发现的唯一解决方案是:带有空"视图的UITableView

What I would like is to display an alternative view when the table has no results. I've googled a lot since yesterday and the only solution I found is this: A UITableView with an "empty" view

...但是我无法使其工作.如果有人有任何提示,或者可以将我指向某个URL来研究解决方案,那将是非常好的,并表示赞赏:)

...but I cannot make it work. If someone has some hint, or can point me to some URL to study the solution, would be great and appreciated :)

感谢您的时间伙伴

推荐答案

您可以将替代视图添加到表格视图下方.当搜索栏中没有文本时,请将表视图隐藏起来,以便其下方的视图得以显示.当要显示搜索结果时,请隐藏备用视图,并将tableview的hidden属性设置为FALSE.

You can add the alternate view below your tableview. When there is no text in the search bar, make the tableview hidden so that the view below it shows through. When you have search results to display, make the alternative view hidden and make the tableview's hidden property to FALSE.

这篇关于当SearchBar不返回结果时,在TableView顶部显示替代视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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