简体   繁体   English

跨多个视图的 UISearchDisplayController

[英]UISearchDisplayController across multiple views

Is is possible to use the same UISearchDisplayController/UISearchbar/UISearchDisplayController ResultsTable logic across multiple views?是否可以跨多个视图使用相同的 UISearchDisplayController/UISearchbar/UISearchDisplayController ResultsTable 逻辑?

I have an application which utilizes a site wide search, using a UISearchBar above nearly every view, therefore i have a lot of duplication throughout the application as each view has a UISearchDisplayController and integrated conditional statements in the tableView's to display the results.我有一个利用站点范围搜索的应用程序,在几乎每个视图上方都使用 UISearchBar,因此我在整个应用程序中有很多重复,因为每个视图都有一个 UISearchDisplayController 和 tableView 中的集成条件语句来显示结果。

Is there a better approach?有更好的方法吗? It feels wrong doing it this way and there must be a better approach that avoids all of this repetition.这样做感觉不对,必须有更好的方法来避免所有这些重复。

I should point out that my application is a Navigation based application utilizing a UINavigationbar hierarchy我应该指出,我的应用程序是基于导航的应用程序,它使用 UINavigationbar 层次结构

You could factor out the common code into it's own class, and then if there is any specific behavior needed by any one implementation, you can override specific methods (such as cellForRowAtIndexpath or didSelectCellForIndexPath).您可以将通用代码分解为它自己的 class,然后如果任何一种实现需要任何特定行为,您可以覆盖特定方法(例如 cellForRowAtIndexpath 或 didSelectCellForIndexPath)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM