Giter Site home page Giter Site logo

dcintrospect-arc's Introduction

#DCIntrospect-ARC

Build Status

Twitter: @lukaswelte
Website: http://lukaswelte.de

DCIntrospect was originally done by domesticcat and 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.

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 you're 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.

Bitdeli Badge

dcintrospect-arc's People

Contributors

futuretap avatar hsoi avatar ksuther avatar lukaswelte avatar miklselsoe avatar neilkimmett avatar popraduvmp avatar shepting avatar vgrichina avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dcintrospect-arc's Issues

Initial setup help

I'm having a bit of trouble getting this setup.

I downloaded the zip from Git and added the files to my project. In my AppDelegate, I imported "DCIntrospect.h", then set the introspector to start:

 [_window makeKeyAndVisible];
 [[DCIntrospect sharedIntrospector] start];

The app launches in the Simulator, but pressing Spacebar does nothing.
Thanks for any help!

ARM64: unknown register name 'eax' in asm

When building DCIntrospect under ARM64:

DCIntrospect.m:621:4: error: unknown register name 'eax' in asm
                        DEBUGGER;
                        ^
DCIntrospect-ARC/DCIntrospect.m:56:225: note: expanded from macro 'DEBUGGER'
#define DEBUGGER do { int trapSignal = AmIBeingDebugged () ? SIGINT : SIGSTOP; __asm__ __volatile__ ("pushl %0\npushl %1\npush $0\nmovl %2, %%eax\nint $0x80\nadd $12, %%esp" : : "g" (trapSignal), "g" (getpid ()), "n" (37) : "eax", "cc"); } while (false);
                                                                                                                                                                                                                                ^
1 error generated.

Not sure how to fix it or what this code actually does.

Stack overflow calling method UITextInputTraits_valueForKey

I am using a project called HTAutocompleteTextField to autofill the user email domain name. When i go to any form which uses this control DCIntrospect goes into an infinite by calling this method UITextInputTraits_valueForKey. This issue is reproducible 100% of the time.
screen shot 2014-03-25 at 2 49 39 pm
screen shot 2014-03-25 at 2 54 29 pm

Infinite loop in setInvokeGestureRecognizer:

  • (void)setInvokeGestureRecognizer:(UIGestureRecognizer *)newGestureRecognizer
    {
    UIWindow *mainWindow = [self mainWindow];
    [mainWindow removeGestureRecognizer:self.invokeGestureRecognizer];

    self.invokeGestureRecognizer = nil;

Add the ability to tag and display tags of views.

To make it easier to read debug logs, add this category and make it so that when you tap on a view, it displays the tag name along with the class name. Also, the debug output should display these tags.

e.g.

[myview setNametag:@"My main view"]

when you tap on it, DCIntrospect should display "UIView - My main view {{0,0},{320,568}}" on the top status bar. Without this, you would only see "UIView" which is not helpful when you have many views and subviews!

Category code:

@interface UIView (NameTags)

  • (NSString *)nametag;
  • (void)setNametag:(NSString *)theNametag;
  • (NSString *)objectIdentifier;
    @EnD

@implementation UIView (NameTags)

  • (NSString *)nametag {
    return (NSString *)objc_getAssociatedObject(self, @selector(nametag));
    }

// Nametag setter

  • (void)setNametag:(NSString *)theNametag {
    objc_setAssociatedObject(self, @selector(nametag), theNametag, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
    }

// Return 'Class description : hex memory address'

  • (NSString *)objectIdentifier {
    return [NSString stringWithFormat:@"%@:0x%0x", self.class.description, (int) self];
    }

@EnD

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.