What would cause the iPhone home screen to be visible behind a modal flip transition?
Asked Answered
M

5

9

On some occasions, not every time, when my app presents a modal view controller using presentModalViewController:animated: with modalTransitionStyle set to UIModalTransitionStyleFlipHorizontal the iPhone home screen is visible behind the animation. Most of the time the background is black as expected. There is nothing abnormal where I set up the window or rootViewController (a UITabBarController). I blacked out my app UI but you can see the issue in the screen shot taken with an iPhone 4 while the transition is in progress.

What would cause this? I don't know how to do it even if I wanted this behavior.

EDIT: This screen shot was sent to me by a tester, I haven't repro'ed it myself. They told me it occurred during a particular app session and once it occurred it happened for all transitions. When they quit/relaunched the app it didn't happen again and they haven't seen it since. I'm wondering whether it's something I need to be concerned about (i.e. I can prevent it in code).

EDIT 2: This app does not use IB. All controllers/views are created in code.

enter image description here

Morphine answered 29/12, 2011 at 23:24 Comment(7)
This is odd it sounds a bit like a bug. Not ideal if you can't reproduce it. Do you set the background color of the UIWindow at any point maybe explicitly setting that might potentially avoid this but that's pure speculation.Arv
I don't set backgroundColor (or any other display properties) of the window. I tried to repro it by explicitly setting the window background color to clearColor (and messed with the tabBarController.view etc). If I could force this to happen that might give me some insight, haven't found a way to do that yet.Morphine
Yup that was my thinking. Although the new Apple templates tend to explicitly set the window self.window.backgroundColor = [UIColor whiteColor]; I could be wrong but chances are it was a similar situation with the xibs pre xcode 4.xArv
ah, should also note I'm creating all views/controllers in code, no IB. I'll edit the question to clarify.Morphine
The main point I was trying to make was that the template explicitly set self.window.backgroundColor = [UIColor whiteColor];. The xib stuff was not really relevant.Arv
I know, thanks for the input. I clarified it in case it spurs any creative ideas for anyone else related to differences between creating windows/views in IB vs programmatically. I am now explicitly setting the window background color as well. Would still be nice to know more about how this happens and be able to force it.Morphine
Was that tester's device jailbroken?Propagable
R
3

I've had the same problem before. Try using [viewController.view setBackgroundColor:[UIColor blackColor]]; on the view your pushing. Worked for me anyways!

Radiotherapy answered 21/1, 2012 at 2:19 Comment(3)
thanks, I am now doing that but you may not have saw that in the comments. so far no more repro's. it would be nice to know how to explicitly make it happen other than a random (i.e. buggy) event.Morphine
Yeah I feel like it's probably more/less a random thing that happens. I only managed to have it happen a few consecutive times on the iPad, happy programming!Radiotherapy
I'm not sure if this is truly related but I did make this change and as far as I know this has never recurred. I still have never personally seen it. I'll accept this to close it out.Morphine
C
2

This happens when iOS sends memory warning to the app and the app's framework automatically dumps all the view components which are not visible, except the data structures related to the viewController will stay, and when there is a refer to the view it will load the view from the nib again ( in your case loadView is called I guess) you should make sure your view construction code is reconstructable and nullify all objects related to the view components in viewDidUnload method of your view controller.

You can also make it happen by running your app by simulator and when you are in that modal view, trigger the "Memory Warning" simulation from the "Device" menu on the top of your computer screen.

Converge answered 16/3, 2012 at 23:32 Comment(1)
This is not the cause of this issue. Your are correct with regard to how iOS (prior to iOS 6) unloads views in response to memory warnings but that is not the issue here.Morphine
P
0

I'm not sure but I think this may be caused by a bug or modification to the main 'UIApplication.h' code, a problem with the iOS or an issue with the version of Xcode you have.

Seb

Problem answered 31/12, 2011 at 7:35 Comment(0)
C
0

I saw this issue happening even with Facebook iPhone App. Maybe it is Apple's bug.

Can answered 13/3, 2012 at 9:11 Comment(0)
P
0

Instructions to fixing this problem:

  1. Go to the effected XIB and select the View Controller effected.
  2. Go to the attributes panel on the right. Go to View >> Background colour.
  3. Now set the colour you want to back the transition.

Hope this helps :)

Problem answered 30/11, 2013 at 21:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.