GithubHelp home page GithubHelp logo

farooqmulla / dcintrospect Goto Github PK

View Code? Open in Web Editor NEW

This project forked from domesticcatsoftware/dcintrospect

1.0 2.0 0.0 419 KB

Small library of visual debugging tools for iOS.

Home Page: domesticcat.com.au/projects/introspect

License: MIT License

dcintrospect's Introduction

DCIntrospect

Twitter: @patr

Our commercial apps: domesticcat.com.au

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.

Introspect Demo Image

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
  • 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. DCIntrospect will not run without that set to prevent it being left in for production use.

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

[window makeKeyAndDisplay]

// always call after makeKeyAndDisplay.
#if TARGET_IPHONE_SIMULATOR
    [[DCIntrospect 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.

A 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: 4 6 8 2 (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. DCIntrospect will try to make sense of the values it can and show more useful info. An example from a UIButton:

** UIRoundedRectButton : UIButton : UIControl : UIView : UIResponder : NSObject **

** UIView properties **
    tag: 1
    frame: {{21, 331}, {278, 37}} | bounds: {{0, 0}, {278, 37}} | center: {160, 349.5}
    transform: [1, 0, 0, 1, 0, 0]
    autoresizingMask: UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin
    autoresizesSubviews: YES
    contentMode: UIViewContentModeScaleToFill | contentStretch: {{0, 0}, {1, 1}} backgroundColor: nil
    alpha: 1.00 | opaque: NO | hidden: NO | clips to bounds: NO |
    clearsContextBeforeDrawing: YES
    userInteractionEnabled: YES | multipleTouchEnabled: NO
    gestureRecognizers: nil

** UIRoundedRectButton properties **

** Targets & Actions **
    target: <DCIntrospectDemoViewController: 0x4c8c0e0> action: buttonTapped:

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.

License

Made available under the MIT License.

Collaboration

If you have any feature requests/bugfixes etc. feel free to help out and send a pull request, or create a new issue.

dcintrospect's People

Contributors

domesticcatsoftware avatar 0xced avatar chrismiles avatar megastep avatar atty303 avatar jessedc avatar johnezang avatar myell0w avatar molescat avatar

Stargazers

Farooq Mulla avatar

Watchers

James Cloos avatar Farooq Mulla avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.