Launch Screen only showing once - ios

I have used the LaunchScreen.storyboard file in my swift file to create a launch screen, however I only see the launch screen when I load the app onto my phone. After that, even when I kill the app I don't see the launchscreen again. I want it so that it shows every time the app is booted, so after it's been removed from the background like most other apps that exist. I there a setting that i need to toggle, or am I doing something wrong?

What you want can be achieved from the initial ViewController instead of Launch Screen.
Reason: Launch Screen timing is not fixed and can have a very short appearance if the app has recently been in the memory.
I would recommend you to use the welcome graphic/animation on the initial View Controller and move to the intended View Controller after a set timer by using a segue.
Edit: Additionally, in case of a graphic, you can put that on the Launch screen as well, then on the initial View Controller. That will get you continuity.
Hope this helps.

Related

How to make animated LaunchScreen in Xcode? [duplicate]

Looking to see where the best place to call some endpoints for initial data is.
In some apps (mostly games) there is a loading screen before the menu. Is this the "Launch Screen" or is it a view set up during viewDidLaunchWithOptions, or is it simply an initial view?
If my searching was correct, there is no way to "perform logic" during the launch screen. So are apps that have a loading screen simply not using a launch screen and just setting up their own loading screen (which appears as a "launch screen")?
You can't execute any code in the launch image or launch storyboard scene, as it is displayed while your app is loading and before it has started executution.
A common approach is to create the first scene of your app to be identical to the launch storyboard scene, so that the transition between the launch image and the initial scene is seamless. You can then perform the loading in the initial scene, while providing appropriate feedback (spinner, progress bar etc)
Mostly it is recommended to use Launch screen Because if your first screen which you are using to shows animation takes long time to prepare itself then user will see white screen. And then perform animations on app's root view controller which always appear at app launch.

iOS app Killed and relaunched Showing my last VC

Killing and relaunching iOS app, If I have View Controller A,B,C last visible View Controller was C. So now when I relaunch app i see View Controller C for 10 sec and then shows up Splash Screen. How can I avoid this.
Because of this first 10 sec User cant perform any event on app.
I think this is an operation system bug. But if you want to avoid this, you can try to add a splash screen image view before your app will go to background. You need to add your custom overlay view as subview to current window. Use this method to implement this feature: applicationDidEnterBackground. You can find more information about this feature here:
Display a view or splash screen before applicationDidEnterBackground (to avoid active view screenshot)
To force iOS to launch an app with its default viewcontroller or launch image, you need to call
UIApplication.shared.ignoreSnapshotOnNextApplicationLaunch()
where you implement state preservation.
Form the documentation : Documentation
Prevents the app from using the recent snapshot image during the next launch cycle.

Proper way to have an initializing screen in iOS application

Looking to see where the best place to call some endpoints for initial data is.
In some apps (mostly games) there is a loading screen before the menu. Is this the "Launch Screen" or is it a view set up during viewDidLaunchWithOptions, or is it simply an initial view?
If my searching was correct, there is no way to "perform logic" during the launch screen. So are apps that have a loading screen simply not using a launch screen and just setting up their own loading screen (which appears as a "launch screen")?
You can't execute any code in the launch image or launch storyboard scene, as it is displayed while your app is loading and before it has started executution.
A common approach is to create the first scene of your app to be identical to the launch storyboard scene, so that the transition between the launch image and the initial scene is seamless. You can then perform the loading in the initial scene, while providing appropriate feedback (spinner, progress bar etc)
Mostly it is recommended to use Launch screen Because if your first screen which you are using to shows animation takes long time to prepare itself then user will see white screen. And then perform animations on app's root view controller which always appear at app launch.

How can I detect if the Launch Storyboard happened?

does anyone know if there is a way to tell if the launch storyboard executed? Or is there a way to detect if the launch image was displayed?
Basically my app consists of just one view controller with some views (all created programmatically), plus the launch storyboard which I added to the project recently which seems to be working OK.
The reason why it would be useful for me to know if the launch storyboard happened is that my app is a game which basically consists of a big 2D scene that you can zoom into and pan around using the usual touch gestures. When the game starts for the first time it starts fully zoomed-out and centered on the scene: so that is what the launch image matches. But the player pans around and zooms-in on various things, so when they press the home button they could be zoomed into any part of the picture. So when they touch the app's icon to relaunch, if the launch storyboard happens it needs to put their pan/zoom position back to the initial centered zoomed-out position (otherwise as soon as the app gets going it would appear to the user to suddenly snap from the initial position represented in the launch image to where they were, not giving a smooth user experience).
What I do at the moment is -- if applicationDidEnterBackground: method gets called I assume that when the user relaunches the app, by touching the icon, that the launch storyboard will be executed. But the launch storyboard doesn't always happen after it hibernated via applicationDidEnterBackground:, especially if it is only a few minutes since the user pressed the home button.... and those times when the launch storyboard does not happen I need not inconvenience the player and put them back to the initial zoomed-out centered position, I could just let them carry on at the position they were.
I've not used storyboards before, but as I understand it launch storyboard are a special case where you can't make any connections to code because your app's not actually running yet, so I can't think of a way to set a variable, for example, to show the story board happened.
Anyone got any ideas?
Cheers,
Jon
Just use the viewDidLoad method provided by the UIViewController.
Just override the method in your ViewController and then you can perform the task you want when your View(Storyboard) is loaded.
Example:
#implementation MyViewController:UIViewController
-(void)viewDidLoad{
//Insert your code here
}
#end

IOS: turn off camera

In my app I use iphone camera, but the process is very low when I open it; then I want to start the process when I shows a splashscreen.
The problem is that when splashscreen ends I don't want to show camera.
Then while I show splashscreen I want to start process of camera and quit it before splashscreen disappear. Is it possible?
First up, Apple specifically advise against using splash screens in their Human Interface Guidelines document. I don't know if your app would get rejected for it, but best not to try.
Second, it sounds like you need to optimise the startup of your application and probably the first view controller. To do this, you need to put off loading/initialising everything you can until it's actually needed (known as "lazy initialisation). All code in applicationDidFinishLaunching: in your app delegate and your view controller's init method, loadView, viewDidLoad, viewWillAppear, viewDidAppear should be reviewed for stuff that could be done later.

Resources