Adding view controller as launch screen - ios

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;
}

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.

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.

iOS 7 red status bar

When Shazam is opened the status bar turns red and doubles it's height because of background recording, but this ruins the UI in my app. I'm now trying to change my code to support different status bar sizes, because the red status bar is also opaque, but I can't come up with a general solution because of this:
When the status bar is initially red, when I launch my app, the launch image is scaled and ruined. How to fix this?
Note: My app does NOT use recording.
[Edit]
The only solution I found was to set 'Status bar is initially hidden' to YES in .plist. I don't really need the status bar to be visible on app launch, especially if it affects my launch image when the status bar is taller than usual, i.e. when recording or during a phone call.
[Edit 2]
There are cases when the launch image will be briefly visible when the app is brought to foreground from background state. To work around this I use view-controller based status bar appearance:
- (BOOL)prefersStatusBarHidden
{
if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground)
{
return YES;
}
return NO;
}
This ensures the status bar is always hidden when the app comes to foreground, so the launch image will never be affected. Don't forget to call setNeedsStatusBarAppearanceUpdate on appDidEnterBackground and (inside an animation block) on appDidBecomeActive notifications.
The red status bar is a system function. You are not going to be able to work around this - and it isn't really your 'fault' if the launch screen looks like that - if the user wants to open your app while using Shazam, they are going to see the red bar and the launch image is going to be scaled. You could change the launch image to look good when scaled, but then it would look bad the rest of the time (when the red bar wasn't at the top of the screen on launch).
After a long long long long long research and hurdles I found out simple solution for this follow as below
In Targets->General->Deployment Info check the HideStatusBar Option
like below!
And in the ViewController (Which one you kept as RootViewController) in viewDidAppear add this line of code...
[[UIApplication sharedApplication] setStatusBarHidden:NO];
Because when you uncheck HideStatusBar Option and your app needs any background process or audio related process then the status bar will become red with enlarged height. If you dont want status bar in entire app then dont add the above line in viewDidAppear and check HideStatusBar Option.

Making launch image disappear faster

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?

Show splash screen at every launch

My app uses a splash screen as per client requirement. I need to display this splash screen at every launch when user presses the home button again. Pressing app I need to load app from beginning or else display splash at a specific time interval.
Please help me to solve this.
You can disable the Multitasking capability of the app and make it start from scratch each time you re-open the app from the home screen.
#implementation MyAppDelegate
- (void) applicationDidEnterBackground:(UIApplication *)application {
exit(0);
}
#end
OR See "Opting Out of Background Execution" in the iOS Application Programming Guide:
"...you can explicitly opt out of the
background execution model by adding
the UIApplicationExitsOnSuspend key to
your application’s Info.plist file and
setting its value to YES."

Resources