Note that there are some explanatory texts on larger screens.

plurals
  1. POUIButton with background image: title text randomly does not appear
    primarykey
    data
    text
    <p>I am setting the background image on a UIButton which has title text. This works fine, except that about 5% of the time, rarely and non-deterministically, with the same code, the text does not appear.</p> <p>In my UIButton subclass:</p> <pre><code>[self setBackgroundImage:normalImage forState:UIControlStateNormal]; // Also set a background image for all other states. </code></pre> <p>In a UIButton category, I have this convenience method for setting the title:</p> <pre><code>- (void)setNormalTitle:(NSString *)title { [self setTitle:title forState:UIControlStateNormal]; [self setTitle:title forState:UIControlStateSelected]; [self setTitle:title forState:UIControlStateHighlighted]; [self setTitle:title forState:UIControlStateSelected | UIControlStateHighlighted]; } </code></pre> <p>I'm not finding this issue having been encountered by anyone. Any ideas? I can always create a custom UIView which contains the button and draws text on top using a UILabel, but I wonder if there's a known issue I'm encountering here.</p> <p><strong>Update</strong>: I seem to have worked around the issue by setting the title asynchronously:</p> <pre><code>_tabCell = loadTopNibObject(@"MYTabSmall3HeaderCell"); dispatch_async(dispatch_get_main_queue(), ^{ _tabCell.tab0Button.normalTitle = @"Option 1"; _tabCell.tab1Button.normalTitle = @"Option 2"; _tabCell.tab2Button.normalTitle = @"Option 3"; }); </code></pre> <p><strong>Update 2</strong>: Nope, the above doesn't work. I've breakpointed and printed out the empty button's text, which reports the correct string even though the button appears blank. I've also tried running <code>setNeedsDisplay:</code> when the button is touched, to no avail. Also tried re-setting the button text to some specific string (e.g. <code>@"test"</code>) on touch but this doesn't kick in any visible letting.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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