开发者

Add a Subview to Splashscreen

I am currently trying to add a Activity Indicator View to my Splashscreen. It only should appear once - at the first start of the App. Some images are created that are needed for the App, but it takes some time.

While the images are created, the Splashscreen is still visible. So I thought it could ma开发者_如何学Cybe be possible to add a Activity Indicator as a Subview of the Splashscreen or at least add it somehow over the Splashscreen.

Is there a possibility to make this possible?

Thanks for your help in advance.


You will need to add the "Splashscreen" as top most view to your window, the "splashcreen" it self is not a view. The system wil just display the default.png:

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

    splashScreen = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, -20.0f, 320.0f, 480.0f)];
    splashScreen.backgroundColor = [UIColor blackColor];
    splashScreen.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Default" ofType:@"png"]];
    [self.window addSubview:splashScreen];

    [self.window makeKeyAndVisible];

    [self performSelector:@selector(applicationDidStart) withObject:nil afterDelay:0.1];

    return YES;
}

splashScreen is a class variable, you could add an Activity Indicator to the splashView.

Then in the applicationDidStart did start methods place the code that will take some time:

- (void) applicationDidStart {
    // some thing that takes a while

   [splashScreen removeFromSuperView];
   [splashScreen release], splashScreen = nil;
}


I dont think it is possible to add a subview to the Splash Screen.

There is a workaround where in you can push an intermediate view on applicationDidFinishLaunching and have the background image of the view as same as that of the splash screen.

Now you can do the stuff where your images are created on this view.

Once images are created, Call a method in applicationDelegate which will pop the intermediate view and add your regular view.

Hope this helps you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜