AppDelegate中的presentViewController在iOS8中有延迟 [英] presentViewController in AppDelegate with delay in iOS8

查看:166
本文介绍了AppDelegate中的presentViewController在iOS8中有延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在iOS7中有一个完整的工作解决方案,通过appDelegate的didFinishLaunching中的presentViewController显示一个LoginViewController。

So I had a full working solution in iOS7 that displays a LoginViewController via presentViewController in the AppDelegate's didFinishLaunching.

基本上我做的是这样的事情:

Basically I am doing something like this:

UIViewController *backgroundViewController = ...
self.window.rootViewController = backgroundViewController;
[self.window makeKeyAndVisible];

[self.window.rootViewController presentViewController:loginViewController
                                             animated:NO ...]

在iOS8中,我看到了一个跳跃。首先,我看到backgroundViewController然后大约1秒钟左右登录出现。

In iOS8 I see a jump. First I see the backgroundViewController then after about 1 second or so the login appears.

那么,我如何防止iOS8中的这种跳跃?

So, how can I prevent this jump in iOS8?

我看到开发人员的https://devforums.apple.com/message/1014384#1014384>一吨 使用此某种问题但仍未找到解决方案。

I am seeing that are a ton of developers with this kind of problem but still didn't find a solution.

推荐答案

也是一个黑客(现在),但只有一行代码

Also a hack (for now), but just one line of code

添加视图您在演示前向窗口呈现的视图控制器

Add the view of the view controller you're presenting to the window before presentation

UIViewController *viewController = [[UIViewController alloc] init];
[viewController.view setBackgroundColor:[UIColor greenColor]];

//  Temporary iOS8 fix for 'presentation lag' on launch
[self.window addSubview:viewController.view];

[self.window.rootViewController presentViewController:viewController animated:NO completion:nil];

如果您要呈现导航控制器而不是添加导航控制器的视图而不是其顶视图控制器。

If you are presenting a navigation controller than add the navigation controller's view instead of its top view controller.

这篇关于AppDelegate中的presentViewController在iOS8中有延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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