Making launch image disappear faster - ios

In order to make my app launch faster so I can start contacting with the server I made AppDelegate launch fast by cleaning all kind of work like this:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//[self redirectConsoleLogToDocumentFolder];
[[Ubertesters shared] initialize];
return YES;
}
What I want to achieve is loading my app faster to splash screen and show in the middle of the screen some kind of spinner (SVProgressHUD or UIActivityIndicatorView), so far I'm putting the spinner in the splash screen viewWillAppear.
This is what happens: didFinishLaunchingWithOptions load fast, then SplashScreen-viewDidLoad load fast and then viewWillAppear took a few seconds, but most of the way I see the image I set up as launch image and not my SplashScreen image with spinner animation.
Any ideas how can I make the launch image disappear faster and show my animation?

Related

add two splash screen with .gif and normal image in ios

I have two images for splash image in which one is simple image and second one is .gif file. If app open only first time, i want to show .gif file as splash screen. If app isn't open first time,i want to show normal images as splash screen.
how can do this by code.
You can use, AppDelegate's Life Cycle Methods, to determine when you want to show what.. Use these methods..
You can easily use a BOOL to determine whether your app is in running state of killed state, see below
- (void)applicationDidEnterBackground:(UIApplication *)application {
wasInBackground=YES;
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
if(wasInBackground){
//Notify to show splash screen using simple image
wasInBackground=NO;
}
}
Hope this helps.
Cheers.

Adding view controller as launch screen

I am working on a launch screen where I want to add a progress bar.
LaunchScreen.xib doesn't allows me to add a progress bar on the launch screen.
So is it possible to add a view controller as the launch screen for some time interval so I can add a progress bar on the launch screen of my project?
No,you can not. You can not add any logic code to it.
And also know that, at launch screen time. Your app is not launched at all. So your code about progress bar is not running.
I think the better way is using a launch screen first,then show a viewController with a progress bar as you like.
Treat launch screen as progress indicator and do loading stuff before return "Yes" in applicationDidFinishLaunchingWithOption.as return yes line executed then view controller load it's view. but don't try too much stuff before return yes like time consuming network operation.
Yes, you can. I wanted to have control how long the LaunchScreen is visible when launching the app which I did in the didFinishLaunchingWithOptions in the AppDelegate.m file.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
int time = 3;
sleep(time);
printf("[%i] %s ***** sleeping %i seconds *****\n",__LINE__,__FUNCTION__, time);
return YES;
}

Setting time for the launchscreen.xib objective c iOS

I am trying to set time for the launchscreen.xib to make it last longer, for example 5 sec,since by default it disappears too quick i searched the web but found nothing useful, can it be done ?
Thanks
The apple documentation mentions this:
A launch file or image provides a simple placeholder image that iOS displays when your app starts up. The placeholder image gives users the impression that your app is fast and responsive because it appears instantly and is quickly replaced by the first screen of your app.
So essentially the launch screen cannot be made last longer because its only displayed when the app is starting up.
Still if you want you can
create a custom UIView with the launch image
make it the Initial View Controller by dropping the arrow in storyboard to your custom UIView
present your main View Controller on top of the launch image view after x seconds using dispatch_after
You can add this in your app delegate:
float delay =5.0;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[NSThread sleepForTimeInterval:delay];
}
If you use a viewController, you can present it again in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
making it the UIWindow's rootViewController, or presenting it modally from your application in the same method. This way, you can customize its dismissal. You can also add some animation to this viewController
So it may be another viewController than your launchScreen.

What exactly happens with app when user presses home button?

What exactly happens with an app when the user presses the home button? Does iOS make a snapshot of current app's state?
If I'm right, how to "slip in" another snapshot? I need it for showing the main iOS screen after user presses home button twice.
In order to achieve that, you could add a subview (i.e. ImageView with an image of your main screen) to your window in - (void)applicationDidEnterBackground:(UIApplication *)application.
When coming back (in - (void)applicationWillEnterForeground:(UIApplication *)application) you have to remove the subview.
However, Apple recommends to always show the latest state of the app (best user experience).
Example of AppDelegate implementation:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
/* other code */
self.overlayView = [[UIImageView alloc] initWithFrame:self.window.bounds];
self.overlayView.image = [UIImage imageNamed:#"mainscreen_screenshot.png"];
/* other code */
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
[self.window addSubview:self.overlayView];
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
[self.overlayView removeFromSuperview];
}
iOS takes screenshot before your application goes to background.
I got it from Apple's official documentation.
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 and we are not able to change its feature.
# sensitive personal information
Set a blurry screen overlay before the app goes in the background and once the app becomes active remove this overlay (check #cweinberger's answer).
If it is iOS 7 or later you can use the function ignoreSnapshotOnNextApplicationLaunch
Also, allowScreenShot flag can be explored in Restrictions Payload.
For deeply read about it Then this is the best documentation.

How to display default image in iPhone App for long time?

Is it possible to display Default image which is shown when iPhone/iPad App starts for long time that what it usually does? Because in my app it varies sometimes that image is displayed for long time and some time is just flashes and it loads main app.
Sumit
Make the first view in your application show the same image as your Default image. You can even show it as a Modal and dismiss it with an animation or after a delay.
Yes you can use [NSThread sleepForTimeInterval:1.0];. Just change the 1.0 to what ever you want. But Apple might not approve your app if you make it stay up too long. It goes against the iOS Human Interface Guidelines.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Add a 1 second delay
[NSThread sleepForTimeInterval:1.0];
// Override point for customization after application launch.
[self.window makeKeyAndVisible];
[self.window addSubview:tabBarController.view];
return YES;
}

Resources