Hi, On Wed, Jun 27, 2012 at 10:30 AM, victoria <[email protected]> wrote:
> Dear list, > > App works fine and Monotouch is awesome. The final showstopper is the silly > user decides to do something else (gasp!) and puts the app in the > background, and when restored later on one of three things happens: > > 1 App returns to where it was, great! > 2 App has been killed by iOS in the background and stars anew, can live > with > that! > 3 Something in-between, and the app freezes. This isn't very good. > You might be able to get a crash report out of these freezes using this technique: http://rolfkvinge.blogspot.com.es/2012/05/monotouch-debugging-tips.html - and with symbolicated crash reports it is usually quite easy to find the reason for hangs. Another (somewhat harsher) method you can try is to handle memory warnings and not do anything at all (in particular do not call the base class implementation of DidReceiveMemoryWarning). This way you'll hopefully end up in case 2) instead of 3) pretty much all the time. > > Up until now I haven't put much thought into the whole > background/foreground > thing and find it surprisingly hard to come by any good resources how to do > this. The reason for the app freezing is probably me not properly restoring > the state of the application, but exactly what is it I need to > save/restore? > > The app I'm working on isn't the most complicated thing ever, but it's not > Hello ViewController either. For one thing, I have quite a few objects in > memory that responds to events. If iOS decides to kill them off, I can see > why the app freezes. If that's even possible? From what I understand, iOS > can "reclaim memory" (without killing the application), but exactly what > would that include? In memory objects? ViewControllers? Subviews? > The app gets a memory warning (DidReceiveMemoryWarning) when the system decides it needs more memory from you. If you release enough memory nothing else happens. If you don't, your app is killed. (Note that UIViewController will handle memory warnings and free stuff by itself). I don't know enough about this to know exactly what is freed though and how you should handle it properly (in my experience the restoration is pretty automatic, but I guess it depends on each app) > > For me, it all comes down to this: When the user returns to the app, I need > to know "what has iOS done to my application" so I know how to respond. > Right now I answer that question with "I have no idea and just hope > scenario > 1 or 2 plays out". > The easy way out is probably to override DidReceiveMemoryWarning as I described above and not call the base method (you need to do this in all your controllers) - this way the answer to "what has iOS done to my application" will be "nothing." (besides killing it :) Rolf > > Any hints or docs on this is very very very much appreciated. This is, I > think, the last issue before I get super rich selling my app for $0 on the > appstore. > > / V > > > -- > View this message in context: > http://monotouch.2284126.n4.nabble.com/What-does-iOS-do-to-my-poor-app-in-the-background-tp4655601.html > Sent from the MonoTouch mailing list archive at Nabble.com. > _______________________________________________ > MonoTouch mailing list > [email protected] > http://lists.ximian.com/mailman/listinfo/monotouch >
_______________________________________________ MonoTouch mailing list [email protected] http://lists.ximian.com/mailman/listinfo/monotouch
