UINavigationController pushViewController中途停止/冻结 [英] UINavigationController pushViewController pauses/freezes midway through

查看:139
本文介绍了UINavigationController pushViewController中途停止/冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过以下方式推送视图控制器:

  [self.navigationController pushViewController:[[UIViewController alloc] init] animated:是]; 

但动画在中途停留半秒。动画未完成。这里是gif;



解决方案

有了更多的细节,我可以想到2个可能的问题。




  • 在代码中添加了影子,将被新的ViewController覆盖。如果是这样,使用ShadowPath或半透明视图(属性Shadow是昂贵的,而动画,这样做)


  • backgroundColor是新的ViewControllerclearColor?我看到了这种奇怪的渲染问题。




尝试:

  UIViewController * vc = [[UIViewController alloc] init]; 
vc.view.backgroundColor = [UIColor whiteColor];
[self.navigationController pushViewController:vc animated:YES];

这是2个可能的问题,我可以想到的顶部有这么少的细节。 / p>




不要使用默认的背景颜色,它会随iOS版本而变化,并且在控件之间不一致,甚至可能不同如果视图是在代码中或从Xib(在相同的iOS版本)中创建的。


I am pushing a view controller via:

[self.navigationController pushViewController:[[UIViewController alloc] init] animated:YES];

But the animation lags/pauses a for half a second mid way through. The animation is not complete. Here's the gif;

解决方案

With out more detail I can think of 2 possible problem with that.

  • Is there Shadow added in code to the view that will be covered by the new ViewController. If it is the case, use ShadowPath or an translucent view instead (the property Shadow is expensive while animating, been there done that)

  • Is the backgroundColor of new ViewController "clearColor" ? I've seen strange rendering problem with that kind of thing.

Try:

UIViewController *vc = [[UIViewController alloc] init];  
vc.view.backgroundColor = [UIColor whiteColor];  
[self.navigationController pushViewController:vc animated:YES];

That is the 2 possible problems I can think of the top of my head with so few detail.


Never rely on the default background color, it has change with iOS version and is not consistant across controls and can even be different if the view is created in code or from a Xib (in the same iOS version).

这篇关于UINavigationController pushViewController中途停止/冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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