Note that there are some explanatory texts on larger screens.

plurals
  1. POIncorrect UIView bounds/drawing in the Simulator
    text
    copied!<p>I've created a single-view test app and added a <code>UIButton</code> and <code>UIView</code> to the <code>UIViewController</code> in the main storyboard. I have resized both the button an view to have the same size.</p> <p><img src="https://i.stack.imgur.com/aJeki.png" alt="enter image description here"></p> <p>In my VC's -viewDidAppear:animated method I dump the frame and bounds of the button and view:</p> <pre><code>- (void)viewDidAppear:(BOOL)animated { NSLog(@"button bounds: %@", NSStringFromCGRect(self.theButton.bounds)); NSLog(@"button frame: %@", NSStringFromCGRect(self.theButton.frame)); NSLog(@"view bounds: %@", NSStringFromCGRect(self.theView.bounds)); NSLog(@"view frame: %@", NSStringFromCGRect(self.theView.frame)); } </code></pre> <p>And here is the output when running in the simulator:</p> <pre><code>button bounds: {{0, 0}, {100, 100}} button frame: {{110, 72}, {100, 100}} view bounds: {{0, 0}, {100, 12}} view frame: {{110, 179}, {100, 12}} </code></pre> <p>When run on a device:</p> <pre><code>button bounds: {{0, 0}, {100, 100}} button frame: {{110, 72}, {100, 100}} view bounds: {{0, 0}, {100, 100}} view frame: {{110, 179}, {100, 100}} </code></pre> <p>I do not understand why the view reports a height of 12 when running in the simulator. The view is drawn incorrectly in the simulator but draws as expected when run on a device. Note that the <code>UIViewController</code>'s topmost <code>UIVIew</code> has "Autoresize Subviews" unchecked (although it doesn't make a difference either way).</p> <p>(Xcode 4.5.2. iOS 6.0)</p> <p>Thanks, CS</p> <p><img src="https://i.stack.imgur.com/puqi3.png" alt="enter image description here"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload