addSubview does not show view on iOS 3.1.3
I have a scroll view which has one UIView
inside which contains the content. I am adding a UIImageView
as a sub of the UIScrollView
(so it should be on top of the content container) and this works on iPhone 3.2+, but on an iPhone running 3.1.3 the image does not show up above the container. My code is something like this:
// add the content container
UIView *contentContainer = [[UIView alloc] init];
[scrollView addSubview:contentContainer];
// add content, etc
// this works in 3.2+
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[scrollView addSubview:imageView];
// tried adding this for 3.1, but still didn't work
[scrollView bringSubviewToFront:imageView];
[imageView setFrame:CGRectMake(point.x, point.y, image.size.width, image.size.height)];
开发者_JS百科Is there something else that I'm missing? Thanks!
Are you also actually setting the contentSize
property of the UIScrollView
?
Found the issue: when I specified the image name, I was not specifying the image extension:
UIImage *image = [UIImage imageNamed:@"myImage"];
If I change this to the following, it works:
UIImage *image = [UIImage imageNamed:@"myImage.png"];
Does iOS know to still look for the "@2x" version if available when the extension is present by chance?
精彩评论