当使用“动画”推送视图控制器时,iOS 应用程序崩溃设置为“YES”,但在“动画”时工作正常设置为“否”
好吧,现在这对我来说真的是令人难以置信,我真的无法理解它的任何意义......我用谷歌搜索了它,但仍然一无所获。
我设置了一个 UINavigationController 来推送根视图控制器。然后,当按下 UIButton 时,根视图控制器会推送一个新的视图控制器(实际上它是一个 TableViewController),这就是事情变得奇怪的地方。
仅当我将“动画”设置为“是”时,该应用程序才会崩溃。
[[self navigationController] pushViewController:listView animated:YES];
如果我更改此设置并将“动画”设置为“否”,应用程序将正常继续并且功能出色...我将“动画”设置回“是”,它再次崩溃。
最终,如果我能保留动画,我会很高兴,毕竟这是 iOS 上最美丽的东西之一,但在目前的情况下,我无法弄清楚发生了什么。
请帮我弄清楚这里可能出了什么问题。
Ok, now this has been really mind-boggling for me and I really can not make any sense out of it... I googled it and still nothing.
I have a UINavigationController set up that pushes a root view controller. The root view controller then pushes a new view controller (actually it's a TableViewController) when a UIButton is pressed, and here's where things get weird.
The app only crashes if I set "animated" to "YES".
[[self navigationController] pushViewController:listView animated:YES];
If I change this and set "animated" to "NO", the app continues normally and functions superbly... I set "animated" back to "YES", and it crashes again.
Ultimately, I would love it if I could retain the animation, it is one of the most beautiful things about iOS after all, but with this current situation, I can't for the life of me figure out what is going on.
Please help me figure out what could be going wrong here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当动画打开时,核心动画将从根视图控制器和新视图控制器访问 CALayer 对象,即视图的绘制部分。当动画关闭时,核心动画不需要根视图控制器的 CALayer 对象。也许您正在根视图中释放某些视图,并且它太快地支持 CALayer 对象。
When the animation is turned on Core Animation is accessing
CALayer
objects, the drawn parts of the views, from both the root view controller and the new view controller. When the animation is turned off Core Animation doesn't need the root view controller'sCALayer
objects. Maybe you're releasing some view in the root view and it's backingCALayer
object too quickly.谢谢伯纳先生,你实际上给了我提示,引导我找到解决方案。问题是,我推送的视图控制器实际上是一个表视图控制器,其单元格是根据 NSArray 中找到的条目动态创建的。我正在 viewDidLoad 函数中初始化 NSArray,但是我已将其设置为自动释放,因此在 CALayer 绘制视图之前它会从内存中释放。
Thank you Mr. Berna, you actually gave me the tip that led me to the solution. The thing is that the view controller I was pushing is actually a table view controller, whose cells are created dynamically based on the entries found in an NSArray. I was initializing the NSArray in the viewDidLoad function, however I had set it to autorelease, so it was being released from memory before the view could be drawn by CALayer.