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 th
To get a the frame information similar to the debugger as an NSString, use NSStringFromCGRect(someView.frame)
NSLog(@"My view frame: %@", NSStringFromCGRect(myView.frame));
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>>
Interestingly, using the getter method to return the view's frame works:
print (CGRect)[view frame]
This gives the expected result:
(CGRect) $2 = origin=(x=0, y=20) size=(width=320, height=48)
But if you try to use dot notation, which I hear so often referred to as being provided simply for 'syntactic sugar':
print (CGRect)view.frame
You get the following error:
error: C-style cast from '<unknown type>' to 'CGRect' is not allowed
If you go to the debugger panel, you can type this in while you are at a breakpoint:
(gdb) print (CGRect) [self frame]
$1 = {
origin = {
x = 0,
y = 0
},
size = {
width = 100,
height = 100
}
}
When using the console debugger you can press the up arrow key to cycle through previous commands. Pressing return without entering a command repeats the last command.
In XCode 5.1.1, you can hover over a variable that is a UIView and you will see the following type of popover:
If you click on the 'i' button, the following type of output will be printed in the debugger's console:
<UIImageView: 0xa49ca90; frame = (0 0; 640 360); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xa46c1c0>>
This is another way of inspecting the frame of a UIView.