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;
}
Related
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;
}
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?
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.
Long story short, I'm trying to change my iOS app's rootViewController on applicationWillEnterForeground:, like so:
- (void)applicationWillEnterForeground:(UIApplication *)application
{
MyViewController *controller = [[MyViewController alloc] init];
self.window.rootViewController = controller;
}
However, when iOS performs the "zoom in" animation that is performed when an app is moved from the background to the foreground, it still shows the previous rootViewController's view. Then, as soon as the animation is complete, the app blasts the new rootViewController's view onto the screen.
One way to solve this is to simply move that code to - (void)applicationDidEnterBackground:, but the problem with this solution is that, in my app, there is no way to tell if a new rootViewController will be assigned until - (void)applicationWillEnterForeground:(UIApplication *)application (it is based on time passed since leaving the app).
How can I force the app to redraw before iOS performs the animation taking the app from the background to the foreground?
I believe this is not possible. The screen that iOS shows of your app when it comes into the foreground is actually a screenshot the system took when the app went into the background. There is no way to manipulate or replace that image at the time the app comes back into the foreground.
This behavior is partly documented in the Moving to the Background section of the iOS Application Programming Guide:
Apps can use their applicationDidEnterBackground: method to prepare for moving to the background state. When moving to the background, all apps should do the following:
Prepare to have their picture taken. When the applicationDidEnterBackground: method returns, the system takes a picture of your app’s user interface and uses the resulting image for transition animations. If any views in your interface contain sensitive information, you should hide or modify those views before the applicationDidEnterBackground: method returns.
Apple does not explicitly document that you cannot modify or replace this screenshot at a later time but neither do they say the opposite anywhere I know of.
I'm reading XML from internet in my AppDelegate inside didFinishLaunchingWithOptions, but the problem is my app got loaded before parserDidEndDocument got triggered!
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[self openXML];
NSLog(#"loaded?"); //target
[self.window addSubview:tabController.view];
[self.window makeKeyAndVisible];
return YES;
}
- (void)parserDidEndDocument:(NSXMLParser *)parser{
NSLog(#"loaded.");
}
How can I hold loading the app until parserDidEndDocument triggered?
Moreover, how can I proceed & continue loading the app if I couldn't load the XML for any reason?
You are going to parse xml in app, so in any way you need to run and load you app at first :). So, if you need to perform some synchronious task in main thread then simply create an empty view with dark backround and UIActivityIndicator, bring this view to user without interactions( perhaps). When task will finished (parserDidEndDocument) just remove that view.