Note that there are some explanatory texts on larger screens.

plurals
  1. PONSTextField's attributed string is delayed in rendering
    primarykey
    data
    text
    <p>I've got an Label (NSTextField) in IB that's bound to a controller. The controller, on awakeFromNIB, sets the attributedStringValue of the label to contain some coloured text and a link or two.</p> <p>When you see the label it contains the correct string value, but some of the formatting is lost - until you click on the label, and it updates to contain the correct formatting.</p> <p>I'm using this code to set the value:</p> <pre><code>[self.testTextField setAllowsEditingTextAttributes:YES]; [self.testTextField setSelectable:YES]; NSMutableAttributedString *linkString = [[NSMutableAttributedString alloc] initWithString:@"hit this "]; [linkString beginEditing]; NSMutableAttributedString* attrString = [[NSMutableAttributedString alloc] initWithString:@"link"]; NSRange range = NSMakeRange(0, [attrString length]); [attrString addAttribute:NSLinkAttributeName value:[[NSURL URLWithString:@"http://google.com"] absoluteString] range:range]; [attrString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSUnderlinePatternDot] range:range]; [attrString addAttribute:NSForegroundColorAttributeName value:[NSColor blackColor] range:range]; [linkString appendAttributedString:attrString]; [linkString appendAttributedString:[[NSAttributedString alloc] initWithString:@" to search"]]; [linkString addAttribute:NSForegroundColorAttributeName value:[NSColor redColor] range:NSMakeRange(0, [linkString length])]; [linkString endEditing]; [self.testTextField setAttributedStringValue:linkString]; </code></pre> <p>Based on this example, you'll see the string coloured red and in the default Label font. Then when you click on the label the font changes size and face and the link magically renders.</p> <p>Any ideas on how to get the string to render correctly the first time? </p>
    singulars
    1. This table or related slice is empty.
    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.
 

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