在 Xcode 中调试时,我可以看到我的应用程序中的视图层次结构吗? [英] Can I see the view hierarchy I have in my app while debugging in Xcode?
问题描述
我正在调试我的 iOS 应用程序,因为我有一个视图推送/解除调用,我想确保我的堆栈中没有任何我不期望的视图.是否可以在 Xcode 调试器中看到这一点?
I am debugging my iOS app and since I have a view push/dismiss calls, I want to make sure I don't have any views in my stack that I wouldn't expect. Is it possible to see this in the Xcode debugger?
推荐答案
您可能会发现 lldb 使用recursiveDescription"来解决问题.只需在您对视图层次结构感兴趣的点设置一个断点.例如,如果您想要窗口中的所有内容,您可以输入
You might find lldb comes to the rescue with 'recursiveDescription'. Simply set a breakpoint at the point where you are interested in the view hierarchy. If for example you want everything in the window you can type
(lldb) po [[[[UIApplication sharedApplication] windows] firstObject] recursiveDescription]
或者,我经常发现在调试视图时,我最感兴趣的是特定视图的层次结构.在这种情况下,您可以直接连接到您感兴趣的代码点(例如 viewDidAppear: 方法)并输入:
Alternatively, I often find that when debugging views I am mostly interested in the hierarchy for a particular view. In that instance you can hook straight in to the point in code you are curious about (for example the viewDidAppear: method) and type:
(lldb) po [self.view recursiveDescription]
注意: 在 Xcode 6 中,Apple 添加了实时视图调试,您可以从调试栏访问它.
Note: With Xcode 6 Apple have added realtime view debugging which you can access from the debug bar.
这篇关于在 Xcode 中调试时,我可以看到我的应用程序中的视图层次结构吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!