Note that there are some explanatory texts on larger screens.

plurals
  1. POUIView subviews not showing up
    primarykey
    data
    text
    <p>In my subclass of UIView (which I have instantiated in Interface Builder), has a couple buttons as subviews that I add to my view in the initWithCoder method like so:</p> <pre><code>theButton = [UIButton buttonWithType:UIButtonTypeCustom]; [theButton setFrame:CGRectMake([UIScreen mainScreen].bounds.size.height-150-10, 289, 150, 21)]; [theButton.titleLabel setTextAlignment:UITextAlignmentRight]; [theButton setOpaque:YES]; [theButton.titleLabel setFont:[UIFont fontWithName:@"MyFont" size:32.0]]; [theButton.titleLabel setTextColor:[UIColor redColor]]; [theButton.titleLabel setText:@"text"]; [self addSubview:theButton]; [theButton addTarget:myTarget action:@selector(pause) forControlEvents:UIControlEventTouchUpInside]; </code></pre> <p>But the button will not draw as it is supposed to. If I set a breakpoint in <code>drawRect:</code>, and <code>po [self subviews]</code> with llvm, I get this output.</p> <pre><code>$0 = 0x0c93e860 &lt;__NSArrayM 0xc93e860&gt;( &lt;UIButton: 0xc93d910; frame = (10 289; 150 21); alpha = 0.5; layer = &lt;CALayer: 0xc93d4a0&gt;&gt;, &lt;UIButton: 0xc93e2d0; frame = (408 289; 150 21); layer = &lt;CALayer: 0xc93e390&gt;&gt; ) </code></pre> <p>So why isn't my button showing up?</p> <p>Edit: my superview's recursiveDescription:</p> <pre><code>&lt;UIView: 0xa46b220; frame = (0 0; 320 568); transform = [0, -1, 1, 0, 0, 0]; autoresize = RM+BM; layer = &lt;CALayer: 0xa46b280&gt;&gt; | &lt;MyView: 0xa168710; frame = (0 0; 568 320); autoresize = W+H; layer = &lt;CALayer: 0xa1687d0&gt;&gt; | | &lt;UIButton: 0xa16c160; frame = (10 289; 150 21); alpha = 0.5; layer = &lt;CALayer: 0xa16bcc0&gt;&gt; | | | &lt;UIButtonLabel: 0xa16c3e0; frame = (0 0; 0 0); clipsToBounds = YES; hidden = YES; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0xa16c480&gt;&gt; | | &lt;UIButton: 0xa16cb00; frame = (408 289; 150 21); layer = &lt;CALayer: 0xa16cbc0&gt;&gt; | | | &lt;UIButtonLabel: 0xa16c7e0; frame = (0 0; 0 0); clipsToBounds = YES; hidden = YES; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0xa16c880&gt;&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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