UINavigationController + UITableView + UISearchBar + UISplitViewController [英] UINavigationController + UITableView + UISearchBar + UISplitViewController

查看:150
本文介绍了UINavigationController + UITableView + UISearchBar + UISplitViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个恼人的问题。我的UISplitViewController的主(左)窗格中有一个带UITableView的UINavigationController。当我进行正常操作时,事情会很好地推进导航控制器。



alt text http://files.droplr.com/files/8851942/WDO5y.working.jpg



但是,当我进行搜索并推送时,就好像它没有考虑导航栏所需的空间。它将新控制器推到最顶端,然后打开导航栏,重叠内容!



alt text http://files.droplr.com/files/8851942/WDRem.search.jpg



我应该添加它在纵向(在弹出菜单中)和在iPhone上进行时工作正常。这是一个UISplitViewController错误吗?

解决方案

好的,我有你的答案 - [我也把这个答案贴到了链接的问题上] -



以下是对我有用的步骤[包含一些伪代码]:



1)因为你正在搜索你肯定已经覆盖 ShouldReloadForSearch - 所以只需添加一段代码来保存/存储 forSeachString 。 / p>

2)这个可能会有很大差异,具体取决于你的应用程序 - 但这一步的要点是你需要清除存储的搜索字符串[设置为null]如果没有加载搜索结果。我在我的UITableViewSource中做到了这一点。我有2个构造函数 - 一个用于完整数据集,另一个用于过滤的[搜索结果]数据集。所以我只是在我的完整数据集构造函数中将其设置为null。是的,你可以毫无疑问地做到这一点,但这就是我做到的。



3)接下来,做原来的回答状态并调用SetActive - [self.searchDisplayController setActive:NO]; 。他们主张在覆盖ViewDidAppear时这样做。我没有这样做...我在 RowSelected 覆盖中推送下一个UIViewController后立即执行此操作。



4)最后,在附有UISearchDisplayController的UIViewController中检查已保存的搜索字符串,如果存在,则执行以下操作:1)再次调用SetActive但这次使用true参数,即 setActive :YES ...然后2)将searchBar文本设置为您保存的搜索字符串值。我在 ViewWillAppear 覆盖中做到了这一点。



长话短说...这对我有用而且它保持着搜索结果。在步骤4中设置searchBar文本是关键...这有效地使过滤器保持不变。



希望这有助于某人


I have an annoying problem. I have an UINavigationController with an UITableView in the Master (Left) pane of my UISplitViewController. When I do normal operations, things push on on to the navigation controller fine.

alt text http://files.droplr.com/files/8851942/WDO5y.working.jpg

However, when I do a search and push things on, it's like it doesn't account for the space the navigation bar needs. It pushed the new controller on at the very top, then puts the navbar on, overlapping the content!

alt text http://files.droplr.com/files/8851942/WDRem.search.jpg

I should add it works fine when doing it in portrait (in the popup menu) and on the iphone. Is this an UISplitViewController bug?

解决方案

OK, I've got your answer- [I also posted this answer to the linked question]-

Here are the steps that worked for me [containing some pseudocode]:

1) Since you are searching you are most certainly already overriding ShouldReloadForSearch- So just add piece of code that saves/stores the forSeachString.

2) This one may vary quite a bit depending on your app- but the gist for this step is that you need to clear out the stored search string [set to null] if no search results are loaded. I did this in my UITableViewSource. I have 2 constructors- one for the full dataset and another on for the filtered [search results] dataset. So I just set it to null in my full dataset constructor. Yeah, you could do it differently no doubt but that's how I did it.

3) Next, do as the original "answer" states and call SetActive - [self.searchDisplayController setActive:NO];. They advocated doing it in override of ViewDidAppear. I didn't do that... I did this immediately after I pushed the next UIViewController in my RowSelected override.

4) Last, within your UIViewController that has the UISearchDisplayController attached- check for your saved search string and if it exists then do the following: 1) call SetActive again BUT this time with a true parameter ie setActive:YES... then 2) set the searchBar text to your saved search string value. I did this in the ViewWillAppear override.

Long story short... this worked for me AND it maintains the search results. Setting the searchBar text in step 4 is the key... this effectively gets the filter to persist.

Hope this helps someone

这篇关于UINavigationController + UITableView + UISearchBar + UISplitViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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