English 中文(简体)
Iphone Splash Screen
原标题:

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];

Does it make a difference doing this :

[window addSubview:defaultImage];

or this :

[tabBarController.view addSubview:defaultImage];

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];

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

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

Help welcome,

Gauthier.

最佳回答

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.

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.

Edit: 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.
}
问题回答

I don t agree with the first statement in the other answer, that says If you add an image to your project named "Default.png" it will act as a splash screen.

Default.png is the launch image. The Apple HIG specifically distinguishes between launch image and splash screen.

In particular, it says

Avoid using your launch image as an opportunity to provide:

  • An “application entry experience,” such as a splash screen
  • An About window
  • Branding elements, unless they are a static part of your application’s first screen

Hence, for a splash screen, use NSTimer or a button for the user to dismiss the splash screen.





相关问题
images sliding continuously with <table> and jQuery

I m trying to write a little test page that circulates images through a window (see image). I have colored boxes inside a table (gray border), with each box being a element. <table id="boxes" ...

WPF 3d rotation animations

I have a few 3d rectangles on my screen that I want to pivot around the Y axis. I want to press down with the mouse, and rotate the 3d object to a max rotation, but when the user moves their mouse, ...

Disable Windows 7 touch animation in WPF

In Windows 7 when you touch the screen there is a short animation that occurs at the touch point. In my WPF app I want to display my own touch points, without showing the one supplied by Windows. ...

jQuery block moving

I wanna move a div block to the top, so I coded like this: CSS part: .movingPart{ margin-top:80px; } jQuery part: $(document).ready(function() { $( #btn ).click(function() { $( .movingPart )....

Direct 2D gnuplot PNG animation?

Can anyone please confirm that yes/no Gnuplot 4.5 (on CVS) can output 2D animated PNG files? I have numerous datasets but one line that I d like to show iteratively in 3 different places in my graph. ...

Visual State Manager VS Animations in WPF

There is a lot of talk about the simplicity of Visual States and the transitions between them in WPF/Silverlight. I have the need to generate animations dynamically at runtime, to animate the ...

Create a ImageIcon that is the mirror of another one

I ll like to know if there is a way to create a ImageIcon that is the mirror of another ImageIcon. Searching on Google, I found how to do it by using many AWT libraries. Is there a way to do it with ...

how to drag in the animation in iphone application?

Iphone application is using the static co-ordinates to reach at some points in the application,which is based on the button event. But what i want is when i drag the item than it should reach at some ...

热门标签