A gadget to track and analyze iOS app views in real time

Source: Internet
Author: User

A gadget that lets you track and analyze your iOS app view in real time (open source)

GitHub Portal: Https://github.com/sx1989827/RunTrace

Objective

As a developer of iOS, often in order to get a bad look at the UI interface, you often encounter such pain points: where is the view from, its parent view, what its sub-view, what happens to its frame, how it suddenly hides, when it will be released, For like automatic layout, the error often surges like a flood, I want to dynamically get a view of the constraints, I want to know how this view at this moment and what other view of the constraints, how to visually show the constraints of this view, and so on a variety of problems, For the normal display of several view often overtime, painful. I feel the same way about being an iOS developer. So, I wrote this gadget, as an app embedded, fully decoupled, safe and convenient without side effects, I hope you like it.

Update

Updated to 1.2, pop-up windows are completely rewritten, interactivity is better, operations are simpler than before, and the view stack and hit features are added, the user experience is improved, minor bugs are fixed, and stability is guaranteed.

Installation

1. Move the RUNTRACE.H,RUNTRACEHELP.XIB,LIBRUNTRACELIB.A three files under the Runtrace directory to your project, or simply copy the folder to the past. Now there is no need to write a line of code, run your app, in the upper right corner of the interface, a cute little green small button that says T appears.

2. If you use Cocoapods, then add pod "Runtrace" to Podfile.

Disable

Because this tool is for developers debugging, so when the official release must be disabled, disable do not need to remove files, in RunTrace.h the value of the Runtraceopen macro is changed to 0.

Use

Get basic information about a view

Drag the Circle button to the view you want to get information on, and it can get any view you want, whether it's on the TabItem, on the Navigationitem, or even on the UIWindow, you can get it. Clicking on the Information Bar at the top will bring up a window, listing the basic information for the view in the General list.

Get the parent and child views of a view

To see what the parent view or child view of this view is, drag the round button to the view you want to get information from, click on the Information Bar at the top, and a window will pop up. In the Superviews and Subviews lists the view's parent view (in this order) and sub-view (in order from the Inside Out), click to enumerate the views of the information, there is a back button in the upper right corner, click can be a layer of return to the original view. When you don't know which view information is currently being acquired, the hit button can quickly help you navigate to which view you are currently viewing.

Show Automatic layout information

To get the view you want, in the pop-up window, the constrains list shows the view's Automatic layout constraints, click on the list, and the corresponding constraint is highlighted on the page.

Track the status of a view

Many times, we track the state and properties of a view in real time, such as its frame changes, its center changes, its superview changes, its subview changes, its contentsize changes, and so on, Now you can do what you want with a button. Click the Start button on the trace list in the pop-up window to track the status of the view, and the view's update information is all in the list, and when you click Stop, it stops tracking.

Monitoring memory leaks

There is no mistake, it can monitor memory leaks, yes, then how to do it, you push into a viewcontroller, casually get a view of the information, and then pop back, if the memory normal will pop up Removefromsuperview prompt box, If it does not eject, it means that the Viewcontroller has a memory leak.

Principle

After talking about the general use, we come to the simple principle, the principle is the first method swizzling modify the entrance of many methods, add what we want, such as the small circular button, and then through the view of the hittest to get the view we want, KVO can track some of the status of a view's related properties. In fact, the principle is not difficult, but the details are very troublesome, especially in the writing of automatic layout constraints show a lot of things to judge. In addition, we can rest assured that when using the view on the native interface of the app, I use the weak reference, which will not affect your code.

A gadget to track and analyze iOS app views in real time

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.