iPad:根据方向在 applicationDidFinishLaunching 期间添加全屏图像

发布于 2024-12-01 05:28:23 字数 205 浏览 0 评论 0原文

我想在启动iPad应用程序时制作一个“闪屏”:启动时显示默认-[风景|肖像]~ipad.png,之后我想自己添加相同的图像并让它消失出去。

问题是 applicationDidFinishLaunching 期间的方向;我在确定正确图像并将其添加到 UIWindow (似乎是纵向)时遇到问题。

如何在启动期间添加全屏图像然后让它淡出?

非常感谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

软的没边 2024-12-08 05:28:23

您可以将 flashView 添加到 viewDidLoad 中的 RootViewController.view 中:

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

并在 applicationDidFinishLaunching 之后将 alpha 属性设置为 0.0 <代码>RootViewController的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];

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];
著墨染雨君画夕 2024-12-08 05:28:23

您在 application:didFinishLaunchingWithOptions: 期间出现的方向问题属于预期行为;请参阅获取 iPad 应用的启动方向,了解上一个问题正是这个话题。

最好的解决方案是让根视图控制器处理显示启动屏幕,或者使用带有 UIModalTransitionStyleCrossDissolve 的模态视图控制器来显示启动屏幕。这样你就可以对正常的 查看旋转事件并根据需要更改启动屏幕图像。

或者您可以阅读 UIDevice 的 orientation 属性,但这当然有可能不会被更新(即使您从 application:didFinishLaunchingWithOptions: 调用 beginGenerateDeviceOrientationNotifications),直到为时已晚。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文