我推一个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/