How can I display a splash screen for longer on an iPhone?

前端 未结 24 1747
滥情空心
滥情空心 2020-11-27 11:37

How can I display a splash screen for a longer period of time than the default time on an iPhone?

相关标签:
24条回答
  • 2020-11-27 12:31

    There are many options already posted here, but I ran into cocoapod today that allows you to display the contents of your LaunchScreen.xib as the initial view controller:

    https://github.com/granoff/LaunchScreen (Also see this blog post from the author with more implementation details.)

    This seems like a fairly straight-forward way to do this, and better than the vast majority of answers posted here. (Of course it wasn't possible until the introduction of LaunchScreen files in the first place.) It is possible to display an activity indicator (or anything else you want) on top of the view.

    As for why you would want to do this, I'm surprised that no one has mentioned that there are often publisher and/or partner requirements around this sort of thing. It's VERY common in games, but advertising-funded applications as well.

    Also note that this does act counter to the HIG, but then so does waiting to load any content after your application launches. Remember that the HIG are guidelines, and not requirements.

    One final note: It's my personal opinion, that any time an initial screen like this is implemented, you should be able to tap to dismiss it.

    0 讨论(0)
  • 2020-11-27 12:32

    Swift version:

    Add this line in the AppDelegate

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    
        NSThread.sleepForTimeInterval(2.0)//in seconds
    
        return true
    }
    
    0 讨论(0)
  • 2020-11-27 12:33

    Read the Apple iPhone Human Interface Guidelines (HIG). The "splash screen" isn't supposed to be for branding or displaying a logo, it's supposed to look like the default condition of the app so it appears to start up quickly.

    Making it stay there for longer would be a violation of the HIG.

    0 讨论(0)
  • 2020-11-27 12:33

    Make your app take longer to load.

    In all seriousness, Paul Tomblin is correct that this usually isn't a good idea. Default.png is a mechanism intended to make your app appear to load faster by holding an "empty" screenshot. Using it for a splash screen is a minor abuse, but intentionally making that splash screen appear for longer than it needs to is almost sick. (It will also degrade your user experience. Remember, every second the splash screen is visible is a second that the user is impatiently staring at your logo, swearing they'll switch to the first decent competitor they can find.)

    If you're trying to cover for some sort of secondary loading--for example, if the interface has loaded and you're just waiting to get some data from the network--then it's probably okay, and Ben Gottlieb's approach is fine. I'd suggest adding a progress bar or spinner to make it clear to the user that something really is going on.

    0 讨论(0)
  • 2020-11-27 12:34

    in your appDelegate , theres a method called applicationDidFinishedLaunching use a sleep function. Pass a digit in the sleep function for the no. of seconds you want to hold screen.

    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
    {    
        [window makeKeyAndVisible];
        [window addSubview:viewController.view];
        sleep(5);
        return YES;
    }
    
    

    I searched so much for this thing and everybody gave their own complex point of view. I couldn't find a simple way that would just let me do it.

    KISS ( Keep it simple and Smart :) I avoided the actual as its offensive.

    0 讨论(0)
  • 2020-11-27 12:35

    Write an actual splash screen class.

    Here's a freely usable splash screen that I recently posted in my iPhone in Action blog: http://iphoneinaction.manning.com/iphone_in_action/2009/03/creating-a-splash-screen-part-one.html

    0 讨论(0)
提交回复
热议问题