• Stars
    star
    160
  • Rank 234,703 (Top 5 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 12 years ago
  • Updated about 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Visual Debugging Tool. Compatible with the desktop app, View Introspector. Simply, it's a UIView hierarchy viewer library.

CBIntrospector

app icon

Download View Introspector

Introspector is a small set of tools for iOS 6+ and the iOS Simulator 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 iOS simulator, but can also be used on a device.

Introspect Demo Image

View Introspector Screenshot

Download View Introspector

It uses keyboard shortcuts to handle starting, ending and other commands. It can also be invoked via an app-wide UIGestureRecognizer if it is to be used on the device.

Features:

  • Simple to setup and use
  • Compatible with the iOS Simulator companion desktop app - View Introspector
  • Send messages (call any method) to the selected view from the desktop app or from device (tap the status bar) during runtime
  • Controlled via app-wide keyboard commands
  • Highlighting of view frames
  • Displays a views origin & size, including distances to edges of main window
  • Move and resize view frames during runtime using shortcut keys
  • Logging of properties of a view, including subclass properties, actions and targets (see below for an example)
  • Logging of accessibility properties — useful for UI automation scripts
  • Manually call setNeedsDisplay, setNeedsLayout and reloadData (for UITableView)
  • Highlight all view outlines
  • Highlight all views that are non-opaque
  • Shows warning for views that are positioned on non-integer origins (will cause blurriness when drawn)
  • Print a views hierarchy to console (via private method recursiveDescription) to console

Usage

Before you start make sure the DEBUG environment variable is set. CBIntrospect will not run without that set to prevent it being left in for production use.

Add the CBIntrospect class files to your project, add the QuartzCore framework if needed. To start:

[window makeKeyAndDisplay]

// always call after makeKeyAndDisplay.
#if TARGET_IPHONE_SIMULATOR
    [[CBIntrospect sharedIntrospector] start];
#endif

The #if to target the simulator is not required but is a good idea to further prevent leaving it on in production code.

Once setup, simply push the space bar to invoke the introspect or then start clicking on views to get info. You can also tap and drag around the interface.

Provide custom name of the view:

- (void)viewDidLoad
{
    [super viewDidLoad];

    // provide custom names for use by the View Introspector desktop app and console output
	[[CBIntrospect sharedIntrospector] setName:@"myActivityIndicator" forObject:self.activityIndicator accessedWithSelf:YES];
    [[CBIntrospect sharedIntrospector] setNameForViewController:self];
}

Use Interface Builder to set the custom name of the view:

IB Screenshot

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // must be set before any nib is called
    [CBIntrospect setIntrospectorKeyName:@"introspectorName"];
    ...

A small demo app is included to test it out.

Selected keyboard shortcuts

  • Start/Stop: spacebar
  • Help: ?
  • Print properties and actions of selected view to console: p
  • Print accessibility properties and actions of selected view to console: a
  • Toggle all view outlines: o
  • Toggle highlighting non-opaque views: O
  • Nudge view left, right, up & down: a d w s (use the numeric pad) or ← → ↑ ↓
  • Print out the selected views' new frame to console after nudge/resize: 0
  • Print selected views recursive description to console: v

Logging selected views properties

Pushing p will log out the available properties about the selected view. CBIntrospect will try to make sense of the values it can and show more useful info. An example from a UISegmentedControl:

** UISegmentedControl:0x6d5eca0 : UIControl : UIView : UIResponder : NSObject ** 

  ** UIView properties **
    tag: 0
    frame: {{20, 66}, {207, 30}} | bounds: {{0, 0}, {207, 30}} | center: {123.5, 81}
    transform: [1, 0, 0, 1, 0, 0]
    autoresizingMask: UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin
    autoresizesSubviews: YES
    contentMode: UIViewContentModeScaleToFill | contentStretch: {{0, 0}, {1, 1}}
    backgroundColor: nil
    alpha: 1.00 | opaque: NO | hidden: NO | clipsToBounds: NO | clearsContextBeforeDrawing: YES
    userInteractionEnabled: YES | multipleTouchEnabled: NO
    gestureRecognizers: nil
    superview: <UIView: 0x6d4e820; frame = (0 20; 320 460); autoresize = W+H; layer = <CALayer: 0x6d4e8a0>>
    subviews: 2 views [<UISegment: 0x6d5f680>, <UISegment: 0x6d5ef90>]

  ** UISegmentedControl properties **
    removedSegment: nil
    segmentedControlStyle: 2
    numberOfSegments: 2
    apportionsSegmentWidthsByContent: NO
    selectedSegmentIndex: 0
    tintColor: nil

  ** Targets & Actions **

Customizing Key Bindings

Edit the file DCIntrospectSettings.h to change key bindings. You might want to change the key bindings if your using a laptop/wireless keyboard for development. Keep in mind you can use the View Introspector desktop app to interact with the UIView objects as well, and even call methods on the selected view using the View Messenger (see screenshot).

License

Made available under the MIT License.

CBIntrospector and DCIntrospect to CBIntrospect changes by Christopher Bess

DCIntrospect concept and implementation originally created by Patrick Richards domesticcatsoftware.com

More Repositories

1

AutoScrollLabel

Provides marquee like UILabel scrolling, think Music.app track title scrolling. For Obj-C & Swift.
Objective-C
519
star
2

text-sherlock

Text (source code) search engine with indexer and a front end web interface to search. Uses Python 3.
Python
118
star
3

ViewIntrospector

Visual Debugging Tool for the iOS Simulator. A view hierarchy viewer desktop app for CBIntrospect.
Objective-C
48
star
4

inventory-checkin

Inventory check-in/out manager that supports a tablet kiosk.
Python
16
star
5

flask-webapp-bootstrap

Flask webapp w/ admin template project
Python
11
star
6

FirebaseCrud

Android Firebase example: A very simple task list app.
Java
10
star
7

sqbrowser

SQLite Query Browser for any text editor. Uses wxPython 2.8+
Python
8
star
8

CBSearchKit

Simple and flexible full text search for iOS and Mac. Uses the sqlite3 FTS3/4 engine.
Objective-C
5
star
9

mymacros

Helpful Objective-C/C++ macros
C
4
star
10

EvernoteCloudSDK

Evernote Cloud API SDK (Mac and iOS)
Objective-C
4
star
11

AndroidCustomNotifications

Custom Android notification with clickable buttons
Java
4
star
12

CBAsyncTestCase

ObjC Easy Asynchronous Unit Test Case - Synchronize those async operations for testing purposes
Objective-C
3
star
13

json-adhoc

Provides JSON Adhoc environment (for JSON testing)
Python
2
star
14

IBPlayground

Interface Builder Playground
Objective-C
2
star
15

Timber

iOS and Mac app logging made easy. Batteries included.
Objective-C
2
star
16

regexmm

Regex Match Maker - Highlights regex matches, and regex groups for quick regular expression creation. Uses wxWidgets 2.8 GUI.
C++
2
star
17

json-webserver

JSON webserver, echos request back to client
Python
1
star
18

ytlinker

Simple YouTube linker - Flask app to display full video title names for use on iPad or other mobile devices.
Python
1
star
19

qutags-apache-module

qutags Apache PHP/Zend module
Shell
1
star
20

networkcalculator

Network Calculator web app
Python
1
star
21

PartialModalPresentationController

A presentation controller that displays a view controller in a modal overlay style
Swift
1
star
22

qunotefort

Note app - old, old attempt to exercise Qt C++ skills. Uses Qt 3.3
C++
1
star
23

loremjson

Simple JSON file hosting web app
Python
1
star
24

AirshipSender

GUI to send notifications via Urban Airship
Objective-C
1
star
25

CBFlipViewTransition

Flip transition, think iTunes App Store artwork flip to details.
Objective-C
1
star