iPhone addSubview - 子视图不与 UITableView 一起滚动
我使用以下代码在 UITableView 顶部添加一个“微调器”:
spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
[spinner setCenter:CGPointMake(120,162)];
[self.view addSubview:spinner];
spinner.backgroundColor = [UIColor lightGrayColor];
spinner.hidesWhenStopped = YES;
[spinner stopAnimating];
这工作正常,但是当我滚动到 UITableView 的底部并调用微调器时,微调器仍然位于表视图的顶部,在位置 120,162。我希望将其定位在 120、162 - 与 UITableView 所处的位置无关。
I am using the following code to add a "Spinner" on top of my UITableView:
spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
[spinner setCenter:CGPointMake(120,162)];
[self.view addSubview:spinner];
spinner.backgroundColor = [UIColor lightGrayColor];
spinner.hidesWhenStopped = YES;
[spinner stopAnimating];
This works fine, but when I scroll to the bottom of the UITableView and invoke the spinner, the spinner is still up at the top of the table view, at position 120,162. I would like to have it positioned at 120, 162 - independent of what position the UITableView is in.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以添加一个新的子类 UITableCell,其中包含微调器,并将其添加到表格的末尾,并在您通常停止动画时将其拿走,或者让父视图保存您的表格视图并将微调器放在父视图中而不是作为表视图的子视图。我假设你的表视图是你的视图控制器的视图?
you could either add a new subclassed UITableCell with the spinner in it and add it to the end of your table and take it away when you would normally stop the animation, or have a parent view hold your table view and put the spinner in the parent rather than as a child of your table view. I assume your tableview is the view for your viewcontroller?