iOS app black screen after exiting and re-loading - ios

I've seen some other solutions, but none of them are working for me.
My app is suddenly returning to a black screen after I use the home button to leave and then return to the program. It briefly shows the screen and then goes black.
There's nothing inside my appDelegate methods related to foreground and background, and I don't know if there's another bit of code that I should be looking for to solve this issue.
What can cause this to happen?
update:
Upon re-entering the foreground I've checked to make sure that all of the views, subviews, layers and sublayers still exist. Calling setNeedsDisplay to all of them from the WillEnterForeground notification does no good.
Looking at the notifications sent out, there is one called
_UIWindowWillDestroyWindowContextNotification
which looks menacing, but I can't find any information about that.
Any pointers about where to look are much appreciated, I've tried everything that seems possibly relevant. Thanks!!

The most probable cause is you're doing something on the main thread. When the app goes black just click pause on the debugger and check the main thread. If you're not doing something on the main thread please tell us what is your app doing when you click pause.

Related

iPhone UI Updating while Xcode paused at breakpoint

I have an odd UI bug I am tracking down, where my UI in a particular UIViewController subclass shows up mostly ok and then animates itself to be totally ok.
I have tracked down where the "shift" is occurring, but have not yet completely solved the issue. While attempting to track down and fix the bug, I had a very, very odd thing happen.
I set and hit a breakpoint in -(void)viewDidAppear:(BOOL)animated for the UIViewController in question. When the breakpoint was hit, the UI on the attached phone was wrong. Then, while still on the breakpoint, without me taking any action, the UI performed the "shift" to correct the out-of-position frames.
How is this possible? Shouldn't -(void)viewDidAppear:(BOOL)animated fire on the main/UI thread? If so, how is any adjustment being made to the UI while paused?

App view seems to reload back to default after some time

I've come across a strange error while programming my iPhone application. Basically when I leave my application in the background and then access it after a long time (i.e. the entire night while I'm sleeping), the viewDidLoad method seems to be called again even though I did not exit the app (I only double tapped the Home button or I tapped the Home button once) but still left the app in the background. However, if I leave the app on for a short period of time (anytime between a few minutes to a few hours), the viewDidLoad method is not called again and everything is as it should be. After doing some research, I found that it is because the viewDidUnload method is called (after the OS finds that the app is suspended for a long time), which calls viewDidLoad again when we bring the app back up. I found this out through this link: view seems to reload itself but it doesn't seem that there's a way to prevent viewDidLoad from being called when the viewDidUnload is called. Is there any way to prevent this viewDidUnload method from being called again? The thing is I want my app to be running for a long time in the background (i.e. a few days in the background) to collect data. Or, is there no way around this? Any help would be appreciated. Thanks!
EDIT: I have realized that after iOS 5, viewDidUnload is deprecated but this phenomenon still occurs. Any ideas on how to fix it? Thanks!
If you want to do stuff in the background you should look into background tasks.

viewWillLayoutSubviews getting called after applicationDidEnterBackground notification

I'm having an issue where my app is crashing on sleep, and sometimes on home. I'm getting a BAD_ACCESS error in a thread called gpus_ReturnNotPermittedKillClient, which tells me that my app is making UI changes in the background, which to my understanding is a no-go. Therefore, I'm stepping through my code to see what happens on home / sleep, and I find that my breakpoint in my VC's -viewWillLayoutSubviews method is getting hit AFTER the breakpoints in the -applicationWillResignActive and -appplicationDidEnterBackground notifications (in which I'm attempting to stop all updates from an asynchronous callback function).
That doesn't seem to make any sense. From the application's perspective, if it's not cool to do UI updates in the background, why call viewWillLayoutSubviews after you're in the background?
EDIT: It appears to do this even when my app doesn't crash. Could it just be lldb getting things out of order?
I think you simply need to be tolerant of this. Per this tech note, you can't do any GLES rendering in the background. My recommendation would be for your app to set a flag when applicationWillResignActive is called, and then before doing any rendering work you check that flag and don't do the work (and perhaps just call -setNeedsDisplay on the view so that if your app becomes active again it will know to draw that view). You seem troubled by the fact that viewWillLayoutSubviews is getting called "late", but I don't see how that really matters. (i.e. layout != rendering) I would be surprised if your view's -drawRect: method were getting called after applicationDidEnterBackground but I would still say that it would be your responsibility to check a flag and not render if your app is in the background.

ios and a situation involving EXC_BAD_ACCESS

I'm struggling with the following scenario and could use some different perspectives to shed some light on me:
I have a self.backstack which is an array of sections to go "back" to when you hit the back button. I'm getting an EXC_BAD_ACCESS when the back button is hit in a particular situation, but I'm not sure which object the code is mad about because everything seems there.
If you look on the bottom left of the image you'll see that self, backStack, and userInfo are all there. Not only that but their respective prints on are logged in the bottom right.
Any thoughts on what the problem might be? Thanks.
I suspect you have an observer of the notification which has been deallocated before it unregistered for the notifications.
Notifications are synchronous, which means that on the line you are crashing on, it is trying to run all of the observer callbacks. Check everywhere you are registering for these, and make sure the objects are either retained elsewhere, or are being properly unregistered (removeObserver iirc) when they are released.

iphone app - white screen shows when launching, or when app suspends

we're having a bit of a headache with some apps, Perhaps anyone of you may be able to alleviate the pain, here goes:
We have an OpenGLES(1) application, and it works fine on any device yet tested, from ipod touch on 3.2 to iphone 4, ipad 1, with iOS 4.2.
however, when the user clicks 'home' twice while the app is running, the application view moves up to accommodate the phone's 'taskbar', but then the view turns white.
I suspect after reading various posts this is because I have not yet implemented the 'applicationWillResignActive' delegate method, but I'm unsure if this is indeed the case, and if so, how I would go about avoiding the white screen. Incidentally, there is also the problem that the background EAGLView goes white (or away ?) when an UIAlertView is added to the mainWindow.view, which seems to me a related problem.
I would much appreciate any suggestions.
Jonathan
Your framebuffer is being destroyed, probably in EAGLView or somewhere similar.
Rebuild the framebuffer after you get control back.

Resources