Iphone启动画面 [英] Iphone Splash Screen

查看:95
本文介绍了Iphone启动画面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的想尽力而为,但我无法真正找出代码中出现的问题。我做了很多搜索,但我想我无法理解一些客观的c基础知识;)

I am really trying to do my best but I can't really find out what's going wrong in my code. I made a lot of search but I guess I just can't understand some objective c basics ;)

我的第一个问题与下面的代码有关:

My first question is related to the code below :

[window addSubview:tabBarController.view];

UIImage *image = [UIImage imageNamed:@"lol.png"];
UIImageView *defaultImage = [[UIImageView alloc] initWithImage:image];

这样做是否有所不同:

[window addSubview:defaultImage];

或者这个:

[tabBarController.view addSubview:defaultImage];

我的第二个问题是关于创建启动画面。我试图自己做,但我找不到什么不起作用(我们在appDelegate):

My second question is about creating a splash screen. I tried to do it by myself but I just can't find out what's not working (we're in appDelegate) :

[window addSubview:tabBarController.view];

UIImage *image = [UIImage imageNamed:@"lol.png"];
UIImageView *defaultImage = [[UIImageView alloc] initWithImage:image]; 

[window addSubview:defaultImage];
[window makeKeyAndVisible]; //makes the window visible right ?

UIImage *image2 = [UIImage imageNamed:@"lol2.png"];
UIImageView *pubImage = [[UIImageView alloc] initWithImage:image2];

[UIView setAnimationDelegate:self];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:window cache:YES]; //not sure about the forView:window ...

[defaultImage removeFromSuperview];
[window addSubview:pubImage];

[UIView commitAnimations];

嗯,我想因为我打电话给makekeyandvisible窗口应该是可见的,动画应该显示给用户...

Hmm, I guess since I called "makekeyandvisible" window should be visible and animation should be showed to users ...

好吧,我错过了一步因为它不起作用:D。

Well, I am missing a step as it doesn't work :D.

帮助欢迎,

Gauthier。

推荐答案

如果你添加一个图像你的项目名为Default.png,它将作为启动画面。

If you add an image to your project named "Default.png" it will act as a splash screen.

强迫用户查看屏幕不超过必要的时间通常被视为不良。

Forcing your user to look at a screen any longer than necessary is typically considered bad.

如果你确实想要使用addSubview添加一个:应该可以正常工作,如果你想要动画,你可能想要查看CATransitions而不是UIView动画。

If you do want to add one anyways using addSubview: should work fine, if you'd like animation you may want to look into CATransitions instead of the UIView animations.

将闪屏添加到窗口或主视图控制器应该对用户显示相同。

Adding the splash screen to the window or the main view controller should appear the same to the user.

编辑:
尝试此代码段 - 您需要 #include< QuartzCore / QuartzCore.h> 并添加QuartzCore框架

Try this snippet -- you'll need to #include <QuartzCore/QuartzCore.h> and add the QuartzCore framework

// Using a CATransition
    CATransition* transition = [CATransition animation];
    transition.delegate = self; // if you set this, implement the method below
    transition.duration = 0.3;
    transition.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseOut];
    transition.type = kCATransitionMoveIn;
    transition.subtype = kCATransitionFromRight;
    [self.view.layer addAnimation: transition forKey: nil];
    [self.view addSubview: theNewView];

如果您需要在转换完成时执行某些操作,请添加此项:

Add this if you need to do something when the transition is finished:

#pragma mark -
#pragma mark CAAnimation Delegate Methods
- (void)animationDidStop: (CAAnimation*)theAnimation finished: (BOOL)flag
{
    // Whatever you need to do when the animation is done.
}

这篇关于Iphone启动画面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆