UITableView 部分标题中的 UIActivityIndi​​catorView 在方向更改时消失

发布于 2024-09-10 17:45:28 字数 772 浏览 2 评论 0 原文

我有一个 iPhone 应用程序,其中包含分组样式的 UITableView。 在 ViewController 中,我将 UIActivityIndi​​catorView 定义为属性:

self.browsingIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
browsingIndicator.hidesWhenStopped = YES;

我想将此微调器放置在表部分标题之一中:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *sectionHeader = [[[UIView alloc] init] autorelease];
    [sectionHeader addSubview:browsingIndicator];
    browsingIndicator.center = CGPointMake(20, 30);

    return sectionHeader;
}

这是有效的。现在的问题是:一旦我更改设备方向,活动指示器就会消失,只有当我将其拖出可见屏幕并返回时,它才会重新出现。将设备转回原始方向没有帮助,将“hidesWhenStopped”更改为“NO”两者都不。

有人能指出我正确的方向吗?谢谢!

I have an iPhone app containing a UITableView in grouped style.
In the ViewController I defined an UIActivityIndicatorView as a property:

self.browsingIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
browsingIndicator.hidesWhenStopped = YES;

I want to place this spinner in one of the tables section headers:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *sectionHeader = [[[UIView alloc] init] autorelease];
    [sectionHeader addSubview:browsingIndicator];
    browsingIndicator.center = CGPointMake(20, 30);

    return sectionHeader;
}

This is working. Now the problem: Once I change the device orientation the activity indicator vanishes, it only reappears when I drag it out of the visible screen and back in. Turning the device back to the original orientation doesn't help, changing "hidesWhenStopped" to NO neither.

Can someone point me in the right direction? Thanks!

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

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

发布评论

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

评论(2

萌化 2024-09-17 17:45:28

感谢您的回答,迈克,但我认为不是这样。
UIActivityIndi​​catorView 已正确定位并调整大小,但未绘制。当我强制sectionHeader重新绘制(通过将其滚动到视图之外)时,它会在正确的位置旋转,即使在横向方向也是如此。

我尝试显式设置 autoResizingMask,但这并没有改变 the1 的消失。

编辑:无法评论你的答案,如果没有在这里注册,我就没有真正得到帖子/评论,抱歉:-/

Edit2:

[sectionHeader addSubview:browsingIndicator];

似乎是问题的一部分。如果我直接返回浏览指示器,它就可以工作。

现在已经解决了:
如果我在 viewForHeaderInSection 方法之外为节标题定义 UIView,然后返回它,它就可以工作。

Thanks for your answer Mike, but I don't think that's it.
The UIActivityIndicatorView is positioned and resized correctly but it is not drawn. When I force the sectionHeader to redraw (by scrolling it out of view) it spins at exactly the right place, even in landscape orientation.

I tried to explicitly set the autoResizingMask, but that didn't change the1 disappearing.

Edit: Couldn't comment on your answer, I didn't really get the post/comment without registering thing here, sorry :-/

Edit2:

[sectionHeader addSubview:browsingIndicator];

seems to be part of the problem. If I return browsingIndicator directly it is working.

Kind of solved now:
If I define the UIView for the section header outside of the viewForHeaderInSection method and then just return it, it works.

遇见了你 2024-09-17 17:45:28

您想要设置 autoResizingMask 适当调整微调器的属性。

You want to set the autoResizingMask property of the spinner appropriately.

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