Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone -- is it possible to inspect the frame of a UIView in the Xcode debugger?

When the debugger is stopped at a breakpoint, I can't find the frame of any of my UIViews in there.

Is it possible to do this?

EDIT: starting a bounty due to the lack of response. Just to be clear, what I am looking for is a way to see the frame without adding in extra debugging code.

Also, if the answer is "no you can't do it", bounty will go to the best explanation of why you can see some class members but not others.

like image 475
William Jockusch Avatar asked Aug 08 '10 17:08

William Jockusch


People also ask

How do I inspect a variable in Xcode?

When your app pauses at a breakpoint, hover over a variable in your source code to view its current value. If the variable is an image or other type that isn't expressible as text, click the Quick Look button at the upper-right to see a preview of the variable.

How do I Debug UI in Xcode?

First, launch a project with some interesting UI. Project 13, for example, has enough in there to be interesting. Now run the program as normal, then in Xcode go to the Debug menu and choose View Debugging > Capture View Hierarchy. After a few seconds of thinking, Xcode will show you a screenshot of your app's UI.

How do you evaluate expressions in Xcode?

Evaluate a C/ObjC/C++ expression in the current program context, using user defined variables and variables currently in scope. This command takes 'raw' input (no need to quote stuff). -G <gdb-format> ( --gdb-format <gdb-format> ) Specify a format using a GDB format specifier string.

Does Xcode have a debugger?

When you run an application in Xcode, the debugger is automatically started and attached to the process of the application. Click the Run button in the top left or press Command + R. From the moment the application is up and running, we can start inspecting the process and, if necessary, debug it.


1 Answers

Yes, you can do it. While debugging, find the UIView of interest in the variable inspector. Control-click on it and select "Print Description to Console". For example, I did this on the _view ivar of a UIViewController and the following appeared in the console:

Printing description of _view:
<UIView: 0x25b460; frame = (0 0; 320 480); autoresize = W+H; layer = <CALayer: 0x26b740>>

like image 105
Hilton Campbell Avatar answered Nov 08 '22 23:11

Hilton Campbell