开发者

iPad: add fullscreen-image during applicationDidFinishLaunching depending on orientation

I'd like to make a "splash screen" while starting the iPad app: the Default-[Landscape|Portrait]~ipad.png is shown while starting, afterwards I'd like to add the same image by myself and let it fade out.

The problem is the orientation during applicationDidFinishLaunching; I've got problems to determine to correct image and add it to UIWindow 开发者_运维问答(which seems to be in portrait).

How's it possible to add a fullscreen-image during launch and then let it fade out?

Thank you very much!


You can add flashView to your RootViewController.view in viewDidLoad:

flashView = [...]; // save reference to this object
flashView.alpha = 1.0;
[self.view addSubview:flashView];

And after applicationDidFinishLaunching animate alpha property to 0.0 in RootViewController's viewDidAppear:

NSTimeInterval duration = 1.0;
int curve = UIViewAnimationCurveLinear;

 // Setup the animation
[UIView beginAnimations:@"splash fade out" context:NULL];
[UIView setAnimationDuration:duration];
[UIView setAnimationCurve:curve];
[UIView setAnimationBeginsFromCurrentState:YES];

// change alpha
flashView.alpha = 0.0;

// Commit the changes
[UIView commitAnimations];


Your problem with orientation during application:didFinishLaunchingWithOptions: is expected behavior; see Get launch orientation of iPad app for a previous question on exactly this topic.

The best solution is to have your root view controller handle displaying the splash screen, or present the splash screen using a modal view controller with UIModalTransitionStyleCrossDissolve. That way you can react to the normal view rotation events and change the splash screen image as needed.

Or you may be able to read UIDevice's orientation property, but it is certainly possible that this too won't be updated (even if you call beginGeneratingDeviceOrientationNotifications from application:didFinishLaunchingWithOptions:) until too late.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜