UITableView 部分标题中的 UIActivityIndicatorView 在方向更改时消失
我有一个 iPhone 应用程序,其中包含分组样式的 UITableView。 在 ViewController 中,我将 UIActivityIndicatorView 定义为属性:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
感谢您的回答,迈克,但我认为不是这样。
UIActivityIndicatorView 已正确定位并调整大小,但未绘制。当我强制sectionHeader重新绘制(通过将其滚动到视图之外)时,它会在正确的位置旋转,即使在横向方向也是如此。
我尝试显式设置 autoResizingMask,但这并没有改变 the1 的消失。
编辑:无法评论你的答案,如果没有在这里注册,我就没有真正得到帖子/评论,抱歉:-/
Edit2:
似乎是问题的一部分。如果我直接返回浏览指示器,它就可以工作。
现在已经解决了:
如果我在 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:
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.
您想要设置 autoResizingMask 适当调整微调器的属性。
You want to set the autoResizingMask property of the spinner appropriately.