Note that there are some explanatory texts on larger screens.

plurals
  1. POExtremely Weird Thing with UILabel which displays abnormally
    primarykey
    data
    text
    <p>It's hard for me to describe the problem, and I'll use screenshots. They are all from my simulator, when I test in my <code>iPodTouch4</code>, its the same. I have several <code>UILabel</code> s, which are rects in the picture.</p> <p><img src="https://i.stack.imgur.com/kxKjt.jpg" alt="1.Retina display, UILabels"></p> <p>Notice there are black lines on the right of some rects, which is unexpected, because I didn't code any extra behavior except for backgoundColor and frame.</p> <p>When I change <code>UILabel</code> to <code>UIView</code> (nothing else changed), every thing becomes normal! <img src="https://i.stack.imgur.com/bsi7U.jpg" alt="Retina display, UIViews"></p> <p>And when use <code>UILabel</code> not in retina display, we can see clearly than some rects have different width, but according to my code and the log, they have same width! Realllllly Weird! <img src="https://i.stack.imgur.com/FVwA9.jpg" alt="no retina display UILabel"> </p> <p>I can't figure out why. It might be something special about <code>UILabel</code>, but I can't find anywhere int the documentation.</p> <p>[this is how I create labels]</p> <pre><code>NSMutableArray *labels = [NSMutableArray array]; for (NSString *day in [self getDaysOfTheWeek]) { UILabel *dayOfWeekLabel = [[UILabel alloc] initWithFrame:CGRectZero]; [labels addObject:dayOfWeekLabel]; } self.dayOfWeekLabels = labels; </code></pre> <p>[this is where I set their frames]</p> <pre><code>int count = 0; for (UILabel *dayLabel in self.dayOfWeekLabels) { dayLabel.frame = CGRectMake(CELL_BORDER_WIDTH + count*(self.cellWidth+CELL_BORDER_WIDTH), CELL_BORDER_WIDTH, self.cellWidth, self.daysHeader.frame.size.height); dayLabel.backgroundColor = self.dateBackgroundColor; count++; } </code></pre> <p>Just as I mentioned above, simply change these UILabel to UIView in these code make them looks differently.</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.
 

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