justdan0227
justdan0227

Reputation: 1362

Xcode Debug View Hierarchy finding viewcontroller

Does the Debug View Hierarchy in Xcode allow me to see what view controller owns a view?

Upvotes: 11

Views: 6333

Answers (1)

wolfrevo
wolfrevo

Reputation: 2032

Update: Starting with Xcode 9, view controllers are listed right along the view hierarchy in the visual debugger.

You can get the memory address of the selected view from the inspector in Xcode and then use the console to get the view's view controller using -nextResponder.

http://developer.apple.com/library/ios/documentation/uikit/reference/UIResponder_Class/Reference/Reference.html#//apple_ref/occ/instm/UIResponder/nextResponder

UIView implements this method by returning the UIViewController object that manages it (if it has one) or its superview (if it doesn’t)

Upvotes: 17

Related Questions