Matt Langtree

DCIntrospect - Debugging Views in iOS (Update: Video)

DCIntrospect is a tool that I have found to be invaluable to my work/personal projects recently.

From Pat’s project description:

Introspect is small set of tools for iOS that aid in debugging user interfaces built with UIKit. It’s especially useful for UI layouts that are dynamically created or can change during runtime, or for tuning performance by finding non-opaque views or views that are re-drawing unnecessarily. It’s designed for use in the iPhone simulator, but can also be used on a device.

If you are laying out custom views and tracking their position/movement throughout the lifecycle of your app this tool will be quite useful.

I heard about this project via word of mouth a while ago, and a few Swipe Conference speakers were speaking very highly of it.

Three things to check out in the included demo app (and to use in your app):

  1. Hit spacebar to activate DCIntrospect’s inspector in the iOS simulator.
  2. Select any view in your app and press the ‘p’ button on your Mac’s keyboard to dump the properties of that view
  3. Use the arrow keys on your keyboard to nudge views around whilst your app is running (similar to Webkit’s Web inspector) Example of properties logged by DCIntrospect’s inspector:
Output from DCIntrospect
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
** UIImageView : UIView : UIResponder : NSObject **
** UIView properties **
tag: 0
frame: {{147, 20}, {64, 64}} | bounds: {{0, 0}, {64, 64}} | center: {179, 52}
transform: [1, 0, 0, 1, 0, 0]
autoresizingMask: UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin
autoresizesSubviews: YES
contentMode: UIViewContentModeScaleToFill | contentStretch: {{0, 0}, {1, 1}}
backgroundColor: R: 0 G: 0 B: 0 A: 0.00
alpha: 1.00 | opaque: NO | hidden: NO | clips to bounds: NO | clearsContextBeforeDrawing: YES
userInteractionEnabled: NO | multipleTouchEnabled: NO
gestureRecognizers: nil
** UIImageView properties **
drawMode: 0
image:
highlightedImage: nil
animationImages: nil
highlightedAnimationImages: nil
animationDuration: 0
animationRepeatCount: 0

Melbourne Cocoaheads July ‘11 - Talk 2 - Patrick Richards - DCIntrospect from Oliver Jones on Vimeo.