UIScrollView 中的奇怪 UIImageView

发布于 2024-10-24 17:45:35 字数 657 浏览 3 评论 0原文

非常奇怪的行为,使用此代码的屏幕中心有一个圆点,并且笔尖中没有任何内容的 UIScrollview 。我希望 UIScrollview 应该为空。当我滚动屏幕时,该点会模糊并消失。

- (void)viewDidLoad {
    [super viewDidLoad];
    NSArray *subviews = [closetScroll subviews];
    UIImageView *strange=[subviews objectAtIndex:0];
    strange.center = CGPointMake([[UIScreen mainScreen] bounds].size.width/2, [[UIScreen mainScreen] bounds].size.height/2);
    strange.alpha=1;

    NSLog(@"%@",subviews);
}

控制台输出是:

<UIImageView: 0x4b1f780; frame = (380.5 508.5; 7 7); opaque = NO; autoresize = LM; userInteractionEnabled = NO; layer = <CALayer: 0x4b1f820>

有谁知道为什么?

Very strange behavior, there is a round dot in the center of the screen using this code, and a UIScrollview with nothing inside in a nib. I expect that UIScrollview should be empty. The dot blurs and disappears when I scroll the screen.

- (void)viewDidLoad {
    [super viewDidLoad];
    NSArray *subviews = [closetScroll subviews];
    UIImageView *strange=[subviews objectAtIndex:0];
    strange.center = CGPointMake([[UIScreen mainScreen] bounds].size.width/2, [[UIScreen mainScreen] bounds].size.height/2);
    strange.alpha=1;

    NSLog(@"%@",subviews);
}

The console output is:

<UIImageView: 0x4b1f780; frame = (380.5 508.5; 7 7); opaque = NO; autoresize = LM; userInteractionEnabled = NO; layer = <CALayer: 0x4b1f820>

Does anyone know why?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

彡翼 2024-10-31 17:45:35

在放大 UIImageView 并调整配置后,我得出结论,UIImageView 实际上是滚动条,如果启用了水平和垂直滚动,则“空”UIScrollview 内部有两个子视图。

After magnifying the UIImageView and tweaking with configurations, I have come to conclude that the UIImageView is actually the scroll bar, and if horizontal and vertical scroll is enabled, an "empty" UIScrollview has two subviews inside.

我偏爱纯白色 2024-10-31 17:45:35

我有同样的问题。由于这个“特性”,计算子视图的数量可能非常具有欺骗性。

启动应用程序并计算子视图的数量,这将是 1。现在,在模拟器中使用鼠标或在设备上使用手指并从右向左滑动。计算子视图的数量。数字将为 2。

我只能推断出这个额外的 UIImageView 是由 Cocoa Touch 生成的,以便在“弹跳”超出 UIScrollView 边界的末尾时以正确的颜色渲染背景。

I had the same issue. Calculating the number of subviews can be very deceptive, because of this "feature".

Start the application and count the number of subviews, this will be 1. Now, use you mouse in the simulator or finger on the device and swipe from the right to the left. Count the number of subviews. The number will be 2.

I can deduce nothing else than that this extra UIImageView is produced by Cocoa Touch to render the background in the right color when "bouncing" beyond the end of the UIScrollView's bounds.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文