uiviewcontroller - pushviewcontroller 动画缓慢/断断续续

标签 uiviewcontroller uinavigationcontroller pushviewcontroller

我推一个ViewController其中包含的 View 不多,UIScrollView其中包含 10 个 View ,我有一个单例 ViewController并一次次推,不释放和再次分配ViewController ,所以我在 viewDidLoad() 中做的所有事情, 和 viewWillAppear() ,但动画缓慢且断断续续,这可能是什么?

最佳答案

我遇到了一个问题,当 UIViewController A 执行 pushViewController 来推送 UIViewController B 时,推送动画会在大约 25% 处停止,暂停,然后在剩下的过程中滑动 B。

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

修复是 View Controller B 没有在其根 View 上设置 backgroundColor(根 View 是 viewController.view 的值,通常在 loadView 中设置)。在该根 View 的初始值设定项中设置 backgroundColor 解决了该问题。

我设法解决这个问题如下:

// 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;

}

关于uiviewcontroller - pushviewcontroller 动画缓慢/断断续续,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8833631/

相关文章:

iphone - 当我将新 View Controller 推送到 self.navigation Controller 时应用程序崩溃了

iphone - iOS:通过委托(delegate)方法从推送的 ViewController 返回?

iphone - UIViewController 作为弹出窗口

ios - 屏幕左侧的 UIButton(在 iOS 7 导航滑动区域)未突出显示

ios - 为 iOS 中的每个 View Controller 动态添加自定义 View

ios - 在 navigationController 中有一个通用的条形按钮项目

ios - 快速调用ViewController类方法

ios - 设置失败(tintColor)

ios - 使用导航 Controller 处理数据持久性/流的正确方法?

ios - 将 View Controller 插入模态视图 Controller View