Question

Is that possible to add UIActivityIndicator to splash screen of my app?

Iam using following code in delegate.m file and its not working for me ..

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.

    [NSThread sleepForTimeInterval:5.0];  //for running splash screen more time
     UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

    spinner.center = CGPointMake(139.5, 75.5); // .5 so it doesn't blur
   [self.view addSubview:spinner];
    [spinner performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1.0];


    return YES;
}

Please help me

Was it helpful?

Solution 2

Try this...

UIImageView *splashView; // Declare in appDelegate.h

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    splashView = [[UIImageView alloc]initWithFrame:self.window.bounds];
    if (self.window.bounds.size.height > 480)
    {
        splashView.image = [UIImage imageNamed:@"Default-568h@2x.png"];
    }
    else
    {
        splashView.image = [UIImage imageNamed:@"Default.png"];
    }

    [self.window addSubview:splashView];

   // Add your spinner here.

    return YES;
}

Hope i helped.

OTHER TIPS

The splash screen of your app is simply a png file that is static. You cannot add anything to it like a spinner or animation. What you can do however is once the splash screen finishes loading you can show a view that also has the same splash screen and then add the spinner to it programmatically or using interface builder. Basically from the user perspective they can't tell the difference.

I've used this technique before and it works quite nicely.

By the way, your sleep call will freeze your application momentarily. You are better off using an NSTimer so that the OS doesn't terminate your app for not responding.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top