pushviewcontroller 动画很慢/断断续续 [英] pushviewcontroller animation is slow/choppy

查看:28
本文介绍了pushviewcontroller 动画很慢/断断续续的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我推送一个 ViewController 包含的视图不多, UIScrollView 里面包含 10 个视图,我有一个单例 ViewController 并推送它一次又一次地没有释放和分配 ViewController,所以我在 viewDidLoad()viewWillAppear() 中做的所有事情,但是动画又慢又断断续续,怎么回事?

I push a ViewController which contains not too many views, UIScrollView which contains 10 views inside, I have a singleton ViewController and push it again and again without releasing and allocation again the ViewController, so all the things I do it in viewDidLoad(), and viewWillAppear(), but the animation is slow and choppy, what it could be?

推荐答案

我遇到一个问题,当UIViewController A做pushViewController推UIViewController B时,推动画会停在25%左右,停顿,然后把B滑进去剩下的路.

I had a problem where when UIViewController A did a pushViewController to push UIViewController B, the push animation would stop at about 25%, halt, and then slide B in the rest of the way.

这在 iOS 6 上没有发生,但是当我开始使用 iOS 7 作为 XCode 5 中的基础 SDK 时,这开始发生了.

This DID NOT happen on iOS 6, but as soon as I started using iOS 7 as the base SDK in XCode 5, this started happening.

解决方法是视图控制器 B 没有在其根视图上设置背景颜色(根视图是 viewController.view 的值,通常在 loadView 中设置).在该根视图的初始化程序中设置 backgroundColor 解决了这个问题.

The fix is that view controller B did not have a backgroundColor set on its root view (the root view is the one that is the value of viewController.view, that you typically set in loadView). Setting a backgroundColor in that root view's initializer fixed the problem.

我设法解决了这个问题:

I managed to fix this as follows:

// CASE 1: The root view for a UIViewController subclass that had a halting animation

- (id)initWithFrame:(CGRect)frame

{

     if ((self = [super initWithFrame:frame])) {

          // Do some initialization ...

          // self.backgroundColor was NOT being set

          // and animation in pushViewController was slow and stopped at 25% and paused

     }

     return self;

}

// CASE 2: HERE IS THE FIX

- (id)initWithFrame:(CGRect)frame

{

     if ((self = [super initWithFrame:frame])) {

          // Do some initialization ...

          // Set self.backgroundColor for the fix!

          // and animation in pushViewController is no longer slow and and no longer stopped at 25% and paused

          self.backgroundColor = [UIColor whiteColor]; // or some other non-clear color

     }

     return self;

}

这篇关于pushviewcontroller 动画很慢/断断续续的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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