I am building an application. For splash screen I've just taken the default.png into resource开发者_Python百科s folder and set the sleep time into AppDelegate.m. Till here it is working fine , My Application is getting launch with the splash screen for given seconds. Now I want to change the ViewTransition of Flipping the splash screen. How can I do that ?
Thanks
Just add a view with uiimageview and set its image to default.png. load this view in the beginning. After you splash screen unloads this shuld be the you view and then flip it.
You can't do the flip transition with default.png , try to add a view with that image in window and apply transition to that view.
You can't give Transition style to splash screen using deafult.png image.Create another UIViewController with splash image, just dismiss this view controller with required Transition style and time.
After the splash screen loads.Just replace it with your new UIImageView and set flip transition.
all the folks above are correct about two things:
i. You can't add transition to the Default.png ii. You need to add UIView (or UIImageView) in order to add transition.
Here's some sample code for you to use:
AppDelegate.h
@interface AppDelegate: .... {
...
@property (strong, nonatomic) UIImageView *splashView;
...
@end
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
// fade Default.png into next screen
self.splashView = [[UIImageView alloc] initWithFrame:
CGRectMake(0, 0, self.window.frame.size.width, self.window.frame.size.height)];
// get the right image (does not work on simulator)
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
self.splashView.image = [UIImage imageNamed:@"Default.png"];
else {
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
if (UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation]))
self.splashView.image = [UIImage imageNamed:@"Default-Landscape.png"];
else
self.splashView.image = [UIImage imageNamed:@"Default-Portrait.png"];
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
}
if (self.splashView) {
[self.window.rootViewController.view addSubview:self.splashView];
[self.window.rootViewController.view bringSubviewToFront:self.splashView];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.window cache:YES];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];
self.splashView.alpha = 0.0;
[UIView commitAnimations];
}
return YES;
}
Comments
Notice how I have used setAnimationTransition:UIViewAnimationTransitionNone above. Also, you can use delegate to customize (remove the splashView from super view basically) once done.
精彩评论