addSubview 在 iOS 3.1.3 上不显示视图
我有一个滚动视图,其中有一个 UIView ,其中包含内容。我添加一个 UIImageView
作为 UIScrollView
的子部分(因此它应该位于内容容器的顶部),这适用于 iPhone 3.2+,但在运行的 iPhone 上3.1.3 图像没有显示在容器上方。我的代码是这样的:
// 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)];
我还缺少其他东西吗?谢谢!
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)];
Is there something else that I'm missing? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
发现问题:当我指定图像名称时,我没有指定图像扩展名:
如果我将其更改为以下内容,它会起作用:
iOS是否知道在存在扩展名时仍然查找“@2x”版本(如果可用)偶然?
Found the issue: when I specified the image name, I was not specifying the image extension:
If I change this to the following, it works:
Does iOS know to still look for the "@2x" version if available when the extension is present by chance?
您是否实际上还设置了
UIScrollView
的contentSize
属性?Are you also actually setting the
contentSize
property of theUIScrollView
?