Can I see the view hierarchy I have in my app while debugging in Xcode?

后端 未结 3 1969
面向向阳花
面向向阳花 2020-12-20 06:56

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

3条回答
  •  生来不讨喜
    2020-12-20 07:20

    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]
    

    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]
    

    Note: With Xcode 6 Apple have added realtime view debugging which you can access from the debug bar. Real Time View Debugging Xcode 6

提交回复
热议问题