AppDelegate中的presentViewController在iOS8中有延迟

Tia*_*ida 24 appdelegate presentviewcontroller ios8

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

基本上我做的是这样的:

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

[self.window.rootViewController presentViewController:loginViewController
                                             animated:NO ...]
Run Code Online (Sandbox Code Playgroud)

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

那么,我怎样才能防止iOS8的这种跳跃?

我看到这是一吨开发商有这个样的问题,但仍然没有找到一个解决方案.

Som*_*Guy 17

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

在演示之前,将要呈现的视图控制器的视图添加到窗口中

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];
Run Code Online (Sandbox Code Playgroud)

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


小智 0

我在iOS8中也遇到了同样的问题,我找到了解决方案:

ABCViewController *obj = [[ABCViewController alloc] initWithNibName:@"ABCViewController" bundle:nil];                        

CATransition *transition = [CATransition animation];
transition.duration = 0.4;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromBottom;
transition.delegate = self;
[self.navigationControler.view.layer addAnimation:transition forKey:nil];
[appDelegate.navigationControler obj animated:NO];
 obj = nil;
Run Code Online (Sandbox Code Playgroud)

我希望这个解决方案可以帮助您!