iOS Duration of Splash Screen (Default.png) - ios

im using a Default.png file for my iPad-app. It appears correctly but i could'nt find a way to modify the duration of the splash screen. Has somebody any suggestions? Google has many sites that show how to setup the startscreen but could'nt find a solution for my problem.

The first rule of Human Interface Guidelines for Splash Screens is: don't use splash screens. The second rule is: don't use splash screens!:
Supply a launch image to improve user experience.
Avoid using your launch image as an opportunity to provide:
An “application entry experience,” such as a splash screen
An About window
Branding elements, unless they are a static part of your application’s first screen
If you absolutely must include a long-duration splash screen, and have darn good reasons for doing so, the usual approach is to throw up a UIImageView containing a copy of you launch image in, e.g., application:didFinishLaunchingWithOptions: - which should provide the illusion of a lengthy splash screen.
But please don't.

Using a "splash screen" (Logo, etc) is not the idea of the Default.png!
Read the HIG from Apple.
The (splash) screen (named loading screen) is not for a Logo showing or something like this.
When having multitasking enabled, the "splash screen" shows up really rare.
The splash screen should, like the apple apps does, only show the interface coming up in the first application screen without any localized strings, etc.
Also keep in mind:
The faster the iOS Device get, the shorter you can see the Default.png. So avoid using it for any important CI/CD content.

The Default image is displayed while the app is loading and will be dismissed as soon as the app is ready. And there is no API to control that duration.

You can't technically modify the duration that the "Default" image stays there; it is designed to just be a temporary image "foreshadowing" the app actually starting up and isn't specifically designed as a splash screen.
I recommend that you keep the "splash screen effect" by adding an image view to the screen as the app starts in the -application:didFinishLaunchingWithOptions: method. You can then set a timer which calls a method to animate the splash off after the designated time you want it to be. It will be there for a little longer than you specify depending on how long it actually took the app to load up, but it will give the effect you're after.
You can set the image view's image to [UIImage imageNamed:#"Default"] and it will access that Default artwork for you.

You can't change the duration. If you want it be shown longer though, you can add the same image to a view that you show while you're loading your data!

There is a good blog post here on how to create a splash screen using a UIImageView with a timer:
http://nullpointr.wordpress.com/2012/02/19/iphone-dev-how-to-implement-a-splash-screen/
Useful for beginners, who are still learning the best way to do things in iOS.

As #Conrad Shultz answered, splash screen should be used only via the supplied LaunchScreen.storyboard file by Xcode.
However, in rare situations you do want to prolong the splash screen:
Download A LOT of files before the app starts since the app depends on them.
Other reason...
This is the way to do it:
Inside AppDelegate, under didFinishLaunchingWithOptions you should:
Create a VC that has the same splash image and the same constraints
Present it
Dismiss it after a given time
The code:
let splashVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "splash")
window?.makeKeyAndVisible()
if let root = window?.rootViewController
{
root.present(splashVC, animated: false, completion: nil)
let dispatchTime = DispatchTime.now() + 3
// didFinishLaunchingWithOptions will return and this block will be executed afterwards, hence, async..
DispatchQueue.main.asyncAfter(deadline: dispatchTime, execute: {
root.presentedViewController?.dismiss(animated: false, completion: nil)
})
}
}

Related

How to fix/debug a VoiceOver bug?

What's my problem with the VO?
It gets stuck. It focuses only on the status bar (so it doesn't see the app at all) or it focuses temporarily on a header bar in the app (so I can change the focus between about 3 element in that field). Neither switching the VO off and on nor standard gestures can help a user in such a situation.
When exactly does it happen?
The app is quite big so the exact reason is hard to determine. That's why I want to know how you would debug it. But generally the app has login screens and inside screens. When the app starts and immediately goes to one of inside screens, the VO works perfectly. When the app starts and goes through login screens, the VO gets stuck after logging in.
Any code?
To change between the login screens and the inside screens I use UIApplicationDelegate
let storyboard = UIStoryboard(name: "StoryboardName", bundle: nil)
let vc: WantedViewController = storyboard.instantiateViewController(withIdentifier: "WantedViewControllerId") as! WantedViewController
self.window?.rootViewController = vc
self.window?.makeKeyAndVisible()
Maybe it's too big change for the VO. The app uses also JGProgressHUD but I think I checked quite well that it couldn't be a reason.
Any suggestions and questions are welcome!
If you are using native UIKit widgets, then accessibility should be built in and Voiceover should find the widget. If you have a custom widget, you'll need to set isAccessibilityElement.
The presented code caused the issue indeed. I advise people with a similar problem to perform sergue instead:
performSegue(withIdentifier: "SegueToWantedViewControllerId", sender: nil)
Define it in storyboard for example with Kind as Present Modally and Presentation as Full Screen to get the same result but with VoiceOver working.

React Native: change background color of initial loading view

When the React Native app is running at first, there is a white view like the screenshot bellow, how can i change that view's background color? I cannot find the activity in Xcode.
Because in some cases, i restart the app, and users sees a flash (the white screen above), so i need to change the background color.
Thanks in advance.
I just found it in AppDelegate.m
rootView.backgroundColor = [[UIColor alloc] initWithRed:0.0f green:0.64f blue:0.87f alpha:1];
Try changing the LaunchScreen file. It's the first thing that shows up when your app opens (If your bundling takes too long, you will see the white screen again. IMO the best practice is to use splash screen.
Using splash screen, you can dismiss the Splash View (probably an image) in your componentDidMount() function like below.
componentDidMount() {
// do anything while splash screen keeps, use await to wait for an async task.
SplashScreen.hide();
}
Also note that, in production release, there will be no bundling from the local server, so no need to worry that for now.

View is completely black for few seconds in first launch in ios, swift

I was requested to show two Splash Screens when app launch. one
for a specific group of customers and other for another group of
customers. As I know, Apple doesn't allow to show two splash
screens, because it is already signed to Bundle. so I decided to
use an UIImageView and change the image by checking the group.
To check the group I used deep links which provide by the Branch.io. when someone came from the referral link which we created, it show one image and if someone came from normal way we show another image as launch image, instead of splash screen. it works properly.
But when the first launch it shows Black Screen for five to six seconds(considerable time) and show the image.
If it is not the first time, it works properly.(black screen for 1 to 2 second.)
Below is the way which I used to check the condition and show the image in another viewController.
in AppDelegate, inside the didFinishLaunchWithOption method I checked with branch like below.
let branch : Branch = Branch.getInstance()
// branch.setDebug()
branch.initSessionWithLaunchOptions(launchOptions) { (params, error) in
if error == nil {
let clickedBranchlink : Bool = params["+clicked_branch_link"] as! Bool
let isfirstSession : Bool = params["+is_first_session"] as! Bool
if clickedBranchlink == true {
let theReferrer : String = params["referrer"] as! String
if theReferrer == "groupA" {
// in here I checked the group and set userdefault values and navigate to the view which the image view has and show the image according to this condition.
}
}
}
NOTE: is there a way to increase the process of this and reduce the
black screen. do I do this inside a main thread. because first time it
avoid to go through the branch.initSessionWithLaunchOptions and then
it goes through it. hope your help with this.
This initSessionWithLaunchOptions will be called every time you launch the app and the app is not in the background. Given your observation that the issue only occurs the first time the app is installed, my hunch is that you have code running in didFinishLaunchingWithOptions before the Branch initSessionWithLaunchOptions function is called.
The Branch initialization process involves sending a network request and then waiting for a response, so this is always going to take some time - but there will be no difference in the time it takes on install vs. any other open. Start this asynchronous Branch initialization as quickly as possible, before any other code in didFinishLaunchtingWithOptions executes, and you should be able to reduce the time before the splash page displays. This should eliminate any variability in the time it takes to display the splash image that you believe may be related to Branch.

App crashes on return from some share plugins of activityViewController

I've got a TableViewController with static table; one of it's cells houses an UIView named graphArea. The view renders a chart, it's background and an axis line - all inside it's drawRect(). There are also two another views (sunView & markerView), that are made with Interface Builder and used for chart dynamics (moving marker line and point on touch events).
All worked buttery smooth until I've implemented and tried to test a share button, that employs the ordinary activityViewController mechanism.
The magic begins, when one from a couple of share activities, whose share plugin window takes the full screen, is finished (no matter whether sharing succeeded or cancelled). The app crashes.
Discovery using debugger made apparent to me, that the crash happens, because some views, including graphArea, sunView, markerView are nil after return from sharing screen.
Only some of fullscreen share plugins (like preinstalled Mail and Messages, or, in my case, "Download to DropBox" action) lead app to crash. Other fullscreen share plugins do not (tested Telegram, WhatsApp, Skype). No one of those non-fullscreen plugins has ever caused crash (Evernote, Twitter, 2Do etc.).
It looks like graphArea, sunView, markerView are deallocated from memory when "malicious" share plugins take full screen. I haven't figured out, why.
Here's some debug info:
The traceback and assembly of fatalErrorMessage.
The next screenshot shows a part of controller code and properties, that are nil on return from share plugin (gray selection). And yes, they were all non-nil before.
Please, help me! Thank you in advance!
Thank you, Palpatim. My friend also pointed me at the same thing: I've put graphArea.removeFromSuperview() in viewDidDisappear(), and this caused the exception after share plugins, that have .presentationStyle = fullScreen. So at the point, when the app is to show again, there is no more graphArea in on the tableView.

Can I Animate an image iOS8 LaunchScreen.xib

Question:
Are there ways to animate anything within the LaunchScreen.xib file of an Xcode 6 Project targeted to deploy for iOS 8.1+ ?
Context:
I'm looking to make simple animations to convey activity or serve as a distraction to the user while they wait...
Examples:
A Loading Bar
Activity Indicator
Animated GIF
Move a UIImage across the Screen
Rotate an Image
Nope.
The Launch Image is shown only during the time period between when the user chooses to launch your app and when your app has actually started running. During this period, your app can't take any actions such as performing an animation — it's not running yet. The Launch Image is just a static image that, when well designed, helps give the user the impression that your app is ready quickly.
(Some developers ignore the HIG and use the launch image to provide a splash screen, sometimes with an animated presentation. But in those cases, the launch screen is still a static image, and the animation happens once the app begins running — it's just that the first frame of animation drawn by the running app matches the appearance of the static launch image.)
This behavior didn't change with the LaunchScreen.xib feature in iOS 8 — it still appears only before your app is actually running, so it's still a static image. What the LaunchScreen.xib feature gets you is the ability to adaptively produce a launch image for many different device sizes and styles without having to separately design, render, and ship in your app bundle different images for each size/orientation/etc.
If your app isn't actually ready to use by the time it gains control, think about whether the "loading" tasks you're doing at that time really need to be done immediately, or if you can let the user start doing some things right away and do more setup work on a background thread or defer it until it's actually needed.
I don’t use splash screens often but when I do, I want them to open like a book.
In all truth, I’m not a big fan of splash screens and even Apple recommends using a default.png that shows the controls (with no text) of the application:
Display a launch image that closely resembles the first screen of the application. This practice decreases the perceived launch time of your application.
Avoid displaying an About window or a splash screen. In general, try to avoid providing any type of startup experience that prevents people from using your application immediately.
from HIG Guidelines
However, some people love them and one app in particular has a nice implementation splash screen — Path 2.0. When you open Path, you’re greeted with their logo on a red version of the Apple linen texture that animates open like a book (or journal as that’s what Path considers themselves to be).
You can get the source for this project here: https://github.com/jaysonlane/OpenBook
Before we begin, let me preface this with a disclaimer: I am very new to animations in Cocoa so bear with me. If you spot unnecessary or inefficient code, please leave a comment and I’ll tidy it up.
If you haven’t seen the animation, hop on the app store and pick up a copy to see what we’re trying to accomplish. I’ve created a default png that we can use cleverly titled Math (like a Math book that opens, right?) You can download that here (retina) and here.
To get started, let me explain “the trickery” behind what we’ll be doing: we’re going to use the normal default splash system in place to display our default.png. In the App Delegate, once the application has finished launching, we’re going to create a UIImageView on top of our view of that same default.png. We’ll then animate that UIImageView, to rotate open to reveal our view.
So let’s go:
Create a new project, I created one using the single view template but this will work with whatever. Go ahead and set your default.png and default#2x.png to the images supplied. You can do this by clicking the project in the navigation pane on the left, click the Target and scroll down to launch images:
Open your AppDelegate.m and add the following code to your application didFinishLaunching or application didFinishLaunchingWithOptions function:
//1. add the image to the front of the view...
UIImageView *splashImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
[splashImage setImage: [UIImage imageNamed:#"Default"]];
[self.window addSubview:splashImage];
[self.window bringSubviewToFront:splashImage];
//2. set an anchor point on the image view so it opens from the left
splashImage.layer.anchorPoint = CGPointMake(0, 0.5);
//reset the image view frame
splashImage.frame = CGRectMake(0, 0, 320, 480);
//3. animate the open
[UIView animateWithDuration:1.0
delay:0.6
options:(UIViewAnimationCurveEaseOut)
animations:^{
splashImage.layer.transform = CATransform3DRotate(CATransform3DIdentity, -M_PI_2, 0, 1, 0);
} completion:^(BOOL finished){
//remove that imageview from the view
[splashImage removeFromSuperview];
}];
Three things are happening here…
1) We create a new UIImageView and add it to the top of the view
2) We set an anchor point on the left side of the image to make it open from the left and then reset the frame to the full size of the view
3) We animate the UIImageView and remove it from the view on completion
That’s it, it’s that simple.
Source: http://jaysonlane.net/tech-blog/2012/03/path-2-0-style-animated-splash-screen-default-png/
You can create the LaunchScreen.xib and then create a perfect replica that you can put code on and have a class like LaunchScreenAnimator that you can call form your delegate and that has a delegate to tell you when the animation is over
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
LaunchScreenAnimator *la=[LaunchScreenAnimator createWithDelegate:self];
self.window.rootViewController=la;
[self.window makeKeyAndVisible];
[la startAnimation];
return YES;
}
-(void) splashAnimationFinished:(LaunchScreenAnimator*)view
{
[self startWithDashboardWindow]; // replace the current rootViewController with whatever you want
}

Resources