Black screen on launch, but normal when press home button and enter the app again - ios

As the title, my app will occasionally show a black screen at launch, but I don't know why.
When I press the home button, then entered it again, I saw it was running well. It seems the window could not be made visible randomly. But I don't know when or why does it happen.

You likely don't have a launch image set. When apps are loading their resources they display a launch image, you likely don't have one, which is why you get a black screen.
The reason it doesn't always appear is because if the app is in the background, but still alive, it keeps its resources available for a quick start from the background. It then does not need to display the launch image.
See the Apple documentation

I would say, that there is something wrong with the NavigationController/ViewController stack for Your application. I've had similar situations with exact same problem.
What You can do:
It is pretty hard to suggest something - usually needs tinkering around with the stack structure (maybe try to simplify the stack (remove unnecessary navigationControllers / any tabbarControllers?
Create a separate project, with the same navigationController/ViewController structure, to replicate the problem, upload somewhere, give access to us and we can take a look. But probably - when You will start tinkering around - You will fix the issue Yourself.

Related

I want no launch image but Apple is forcing me to have one

The purpose of launch images is to fake that the app is starting to give time to the app to fully load but I have this app of mine that is so fast to load that the launch image just is visible for less than 0.1 seconds. I have tested the app without the launch image and it loads fast than with a launch image.
When I submit the app to Apple without the launch image it fails validation.
This is ridiculous. Is there a way to solve that?
thanks.
The general rule of thumb is to use a launch image that looks like the first screen of your app with text removed, so it looks like a blank slate of your interface. Once your app starts rendering, it will be obvious to the user that it's reached that point.
Many times games will have a splash screen, especially since they sometimes load resources during that time. So those will usually either have a launch image that is their splash screen, where once rendering it starts it makes some animation occur, or they will sometimes start with a black launch image because the logo/splash will fade in.
As you said, the app fails validation without the launch image. Also when Apple first came out with the iPhone 5, the way you added support for the iPhone 5 screen size was by adding a launch image at that size. So in that case Apple is actually using the presence of the launch image to determine if you support the screen size or not. In other words, you need launch images, and it does help with the user experience, even if it is only visible for a split second.
There is no way to solve it - you must have a launch image.
You could use a launch image that looks a lot like your first page, so it doesn't look so jarring when it briefly flashes up.
Last I checked when you don't have a launch image for a debug build iOS uses a default image. If I remember right it is black. So you could create an all black image and use that.
Ive personally never used a launch image and have gotten all of my apps approved. Maybe you're failing validation because of something else?
you do not need a launch image. This is not causing you to fail validation

Screenshot that taken by iOS when (before) application go into background?

I hope that you all know about it, iOS takes screenshot before your application goes to background.
I got it from official document.
Remove sensitive information from views before moving to the background: When an app transitions to the background, the system takes a snapshot of the app’s main window, which it then presents briefly when transitioning your app back to the foreground. Before returning from your applicationDidEnterBackground: method, you should hide or obscure passwords and other sensitive personal information that might be captured as part of the snapshot.
So, Here We can hide our "sensitive personal information" and the system takes a snapshot of the app’s main window, so we can not change its feature.
But I want to know..
1) If in my application I'm at 4th View, and my app goes to background then system takes screen shot of which view/page? first one (start up view of apps?) or 4th view/page of the app ?? (here is little confusion for me).
2) Can we fire any action when system is taking screenshot or any notification is available that will inform us of system taking screenshot ??
3) I just want to know, is it possible to take screen shot (programmatically) before my application launch ?? If YES then give me suggestion for how to do it. And if NO then where/when I'm able to take screenshot (I mean at which minimum stage of application we'll be able to take screenshot ?) ?
It will take a screen short of the top most view, actually it is taking a screen shot of the window which is displaying your app.
No there is no notification that the screen shot is going to or being taken. You should just handle the handle it in the applicationDidEnterBackground; method. Just a stated in the documentation
No this is not possible, how do you want to execute any code before you app is running? The OS will make the screen shot, just be sure to have everything hidden in the applicationDidEnterBackground;. The minimum state is that your app is up and running.
What I've done is on of my apps is as soon as my app gets pushed to the background place an extra view on my UIWindow. Thus when the screen shot is made this view is captured.
1) There is just one screen. The screenshot is taken of that screen. In your model case that should be the 4th view controller's view. However, it is quite possible that your 4th controller's view does not cover all of the screen or has transparent elements. In that case parts of the 3rd or even 2nd and 1st view controller's view are part of the screen.
It is a screenshot not a view controller shot or anything.
2) You understood the documentation all right. The screenshot is taken after you returned from applicationDidEnterBackground. There will be no further dokumentation.
3) No, you cannot execute any code before your app is invoked. However, I have the feeling that you are looking for something different than you asked literally.
For some other reason I have executed a small program in the simulator by implementing the main function only even without calling UIApplicatoinMain. This is the first point in time where code from your app may be executed, although that would not be exactly "out of the book". If I remember right, the screen was blank/black at that point in time. So if you are asking for a way of creating screenshots of other apps, this is not the way to go forward.
It is not taking a screenshot quite like a user pressing buttons.
This functionality is related to state restoration. When the application goes to the background it flattens the view hierarchy for each screen into a screenshot used for the task manager. If you are opted into state restoration it will also persist the state of the user interface. This means that a person can bring the application back from the background state and potentially see sensitive information that way as well, which may be something you need to handle.
Preventing information from being included in the state screenshot is covered in Tech QA 1838.
1) I'm pretty sure the system will take the snapshot of the current visible view, so the last one on the stack, not the first one
2) Also, there will probably be a Notification to let us know that the system is going to take a screenshot (otherwise how can we hide sensible information? :) ), but I'm afraid we're currently under NDA I guess?
3) What do you mean "take screenshot before my application launch"? Your code starts executing when your application launches, so this question almost makes no sense :-/
You can anywhere in your application take a snapshot of the screen, however, and there are many stackoverflow posts for that

Taking a home screenshot and using it as background of your app

I want to fake a transparent background in my app, so I thought the best way would be to take a screenshot of the home and use it as background.
The only problem comes with the fact that you can't possibly have the app take a screenshot without actually launching the app, so my question would be:
Is there any way to tell my app to take a screenshot of the home?
You may want to rethink your design. You cannot do this without jailbreaking. It would also be very hard to maintain to ensure its up-to-date, and the user would see right past it. In addition, its highly unlikely an app with this method would pass through the review process.

When the device language changes, backgrounded apps quit themselves

I've observed that if I change the device language, and after coming back to home screen, all background processes quit themselves. If I click on a running app icon again, it starts from scratch -- i.e., from application:didFinishLaunchingWithOptions:.
Am I wrong somewhere? What can I do to work around this?
I think this is a nothing odd and a default behavior.
You may want to look into this post if you want to make changes right from inside your application, though I am not sure on how good this is, as I have not personally implemented it.
language change only after restart on iphone
Let me know if you need more help.
Hope this helps you.

What is the purpose of launch images in an iOS application?

How important is it to add Launch Images to an iOS application? I assume that these are like a cached file to show on the screen while the application is getting setup, when there might otherwise be nothing to show until it is fully running. Is this right?
If so, what should a launch image be if your app might start in different states, or does this not effect return to foreground when multitasking? If it is only for the very first initial launch of the app, then the launch image should just be the same as whatever graphic normally appears when you first start the app, right?
Apple must not care too much about whether your app actually includes these, since mine never have.
Note: as Zev mentions below, the Apple HIG recommendation has changed since I originally answered this question. Apple now recommends that you take all of the static elements of your first screen and make that into your default or launch page. All dynamic elements are to be removed, to give the impression that your app is going through an initialization process -- which in some cases may mean that your default screen is simply a background from your app. Thanks to Zev Eisenberg for pointing that out, "splash" pages are not recommended.
The launch image will show while your app is initializing, it's a good idea to have one. If you don't have one the user is likely to stare at a blank screen while waiting for your app to load. I believe the recommendation is to use an image that looks like the first page of your app. Here is the reference:
http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/IconsImages/IconsImages.html#//apple_ref/doc/uid/TP40006556-CH14-SW5
how about if app is starting immediately and no time passed ?
what if you see (or cannot see) for a 0.1 sec launch image ?
would it be still useful to have two images in main bundle that will never be seen or used ?

Resources