Re: iPhone UISearchDisplayController how to handle memory warning
Re: iPhone UISearchDisplayController how to handle memory warning
- Subject: Re: iPhone UISearchDisplayController how to handle memory warning
- From: Matt Neuburg <email@hidden>
- Date: Tue, 15 Feb 2011 11:13:33 -0800
[Sorry to pick this up a month-and-a-half later, but I've only just gotten around to testing.] I can't reproduce the problem. I constructed a test app that I believe is what you're describing:
Navigation Controller
Table View
Table View's header view is a Search Bar
UISearchBarController with this search bar as its search bar
So, I tap in the search bar and the search bar controller takes over the screen, with the search bar at the top. I type something into the search bar and table view items appear. I tap in a table view item, and in response to tableView:didSelectRowAtIndexPath:, I push a new view controller onto the navigation controller's stack.
So far so good. And then when I tap the back button to pop the second view controller off the stack and return to my root view, everything is fine. It's just as it was before; we're still in the search bar controller's interface, the search bar is still at the top of the screen, my text is still in it. I've put a log on didReceiveMemoryWarning and I'm not receiving one. I've tried causing a memory warning manually, and then of course I receive it, but it makes no difference; I still come back to the root view just fine afterwards.
So I'm led to suspect that there's something else odd about the configuration in your app, something omitted from the description. m.
On Jan 3, 2011, at 11:24 AM, Donald Largen wrote:
> Thanks for the reply. I actually had the same idea to start with something simple to recreate the problem. One of those ideas that come to you .5 secs after you hit the send key. I eventually resolved the issue. I did indeed need to handle the memory warning in the ViewController that managed UISeachDisplayController. When this occurs I need to save off the current search text, release the current instance of UISearchDisplayController, and create a new instance. Releasing and recreating was the only way I could get the views to behave properly. Then in the ViewDidLoad set the saved off search text on UISearchBar. This actually performs the search as if the user typed in the text.
>
>
> On Jan 2, 2011, at 3:20 PM, Matt Neuburg wrote:
>
>> On Sat, 01 Jan 2011 10:36:01 -0600, Donald Largen <email@hidden> said:
>>> Here is my situation. I have UIViewController, call it ViewControllerA, that contains an UITableView and UISearchDisplayController. ViewControllerA is the root view controller in a UINavigationController. Things seem to work OK, that is I can preform a search, display the results, and select a row and push a detail view controller onto the stack, call it ViewControllerB.
>>>
>>> The problem I am having is when ViewControllerB is displayed I am getting a memory warning. When I navigate back to ViewControllerA the UISearchDisplayController did something in response to the memory warning. The search bar is gone, the search results table view is gone, the navigation bar is gone, and the "source table view" is displayed but has been scrolled to the top of the screen.
>>>
>>> I am thinking I need to handle this memory warning by recreating the UISearchDisplayController but I am not sure. I have a feeling though I am not doing something right in my setup of the UISearchDisplayController.
>>
>> That's certainly possible, but since you don't show how you set up the UISearchDisplayController, it's impossible to say more. However, in your position here's what I would do: create a completely new minimal project consisting of nothing but a UINavigationController with two UIViewControllers, the first of which has the UISearchBar controlled by the UISearchDisplayController. Now convince yourself that this minimal project does / does not have the problem you describe. If it doesn't, you know it's due to something else you're doing differently in the real project. m.
>>
>> --
>> matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
>> A fool + a tool + an autorelease pool = cool!
>> AppleScript: the Definitive Guide - Second Edition!
>> http://www.apeth.net/matt/default.html#applescriptthings
>
--
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden