UIScrollView subviews not showing at first
Posted
by igul222
on Stack Overflow
See other posts from Stack Overflow
or by igul222
Published on 2010-04-10T03:27:57Z
Indexed on
2010/04/10
3:33 UTC
Read the original article
Hit count: 736
I created a custom UIScrollView subclass that works a like a UITableView, keeping a collection of subviews and re-using them whenever the user scrolls. It's implemented like this:
-(void)layoutSubviews {
for(UIView *subview in [self subviews])
[subview removeFromSuperview];
// then re-add subviews after changing the frame and some attributes
}
This works fine with simple UIViews, but when I try to do it with a UIView that has a UILabel subview, the "base" view appears fine, but the UILabel doesn't show up at all. I can get the UILabel to show up by scrolling the entire UIView off screen and then bringing it back on. What could be causing this?
So far, I've tried calling [myUIView setNeedsLayout]
, [myUIView setNeedsDisplay]
, and [myUIView layoutIfNeeded]
from various places. None of them worked, and the last one crashed my app. I've also done the same thing to myUIScrollViewSubclass
, with similar results.
© Stack Overflow or respective owner