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

前端 未结 24 1748
滥情空心
滥情空心 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:22

    What I did is presented a modalview controller in the initial screen and then dissmiss it after several seconds

        - (void)viewDidLoad
    {
        [super viewDidLoad];
        ....
      saSplash = [storyboard instantiateViewControllerWithIdentifier:@"SASplashViewController"];
        saSplash.modalPresentationStyle = UIModalPresentationFullScreen;
        [self presentModalViewController: saSplash animated:NO];
    }
    
    -(void) dismissSASplash {
        [saSplash dismissModalViewControllerAnimated:NO];
    
    }
    
    0 讨论(0)
  • 2020-11-27 12:23
     Inside your AppDelegate.m
    
        - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
        {
            // Sleep is code to stop the slash screen for 5MoreSeconds
            sleep(5);
    
            [self initializeStoryBoardBasedOnScreenSize];
            return YES;
        }
    

    //VKJ

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

    According to the Apple HIG you should not do that. But if your application needs to do so for definite purpose, you can do:

    • import <unistd.h> in your AppDelegate.m
    • Write the following line at the first of the "application didFinishLaunchingWithOptions:" method

      sleep(//your time in sec goes here//);

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

    I have done this as below:

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"LaunchScreen" bundle:nil];
        UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"splashView"];
        self.window.rootViewController = viewController;
    

    Note: LaunchScreen is the launch story borad and splashView is the storyboardIdentifier

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

    In Xcode 6.3, you can show the launch screen.xib and even put a indicator on it, first it will show the default launch screen it is replaced by the nib so the user doesn't know it changed and then if everything is loaded hide it :-)

        func showLaunchScreen() {
        // show launchscreen
        launchView = NSBundle.mainBundle().loadNibNamed("LaunchScreen", owner: self, options: nil)[0] as! UIView
        launchView.frame = self.view.bounds;
        self.view.addSubview(launchView)
    
        // show indicator
        launchScreenIndicator = UIActivityIndicatorView(frame: CGRectMake(0, 0, 50, 50)) as UIActivityIndicatorView
        launchScreenIndicator.center = CGPointMake(self.view.center.x, self.view.center.y+100)
        launchScreenIndicator.hidesWhenStopped = true
        launchScreenIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
        launchView.addSubview(launchScreenIndicator)
        self.view.addSubview(launchView)
        launchScreenIndicator.startAnimating()
    
        self.navigationController?.setNavigationBarHidden(self.navigationController?.navigationBarHidden == false, animated: true) //or animated: false
    }
    
    func removeLaunchScreen() {
        println("remove launchscreen")
        self.launchView.removeFromSuperview()
        self.launchScreenIndicator.stopAnimating()
        self.navigationController?.setNavigationBarHidden(false, animated: true)
    }
    
    0 讨论(0)
  • 2020-11-27 12:27

    For stylish splash screen tutorial check out this http://adeem.me/blog/2009/06/22/creating-splash-screen-tutorial-for-iphone/

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