添加到 UITableView 时 UIActivityIndi​​catorView 不起作用

发布于 2024-12-07 03:03:15 字数 569 浏览 2 评论 0原文

我试图在等待 UITableViews 数据加载时将 UIActivityIndi​​catorView 添加到 UITableView 的中心。我这样做如下:

UIActivityIndicatorView *activityIndicatorTemp = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleWhiteLarge];
[activityIndicatorTemp setCenter:[[self tableView] center]];
[self setActivityIndicator: activityIndicatorTemp]; 
[activityIndicatorTemp release];
[[self tableView] addSubview:activityIndicator];
[activityIndicator startAnimating]; 

但是,当我启动代码时,活动指示器根本不显示。我想以编程方式执行此操作,有关如何解决此问题或为什么它不起作用的任何建议?

I'm trying to add a UIActivityIndicatorView to the center of my UITableView while it waits for the UITableViews data to load. I am doing this as follows:

UIActivityIndicatorView *activityIndicatorTemp = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleWhiteLarge];
[activityIndicatorTemp setCenter:[[self tableView] center]];
[self setActivityIndicator: activityIndicatorTemp]; 
[activityIndicatorTemp release];
[[self tableView] addSubview:activityIndicator];
[activityIndicator startAnimating]; 

However the activity indicator is not showing up at all when I launch the code. I'd like to do it programmatically, any suggestions on how to fix this or why it isn't working?

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

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

发布评论

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

评论(2

り繁华旳梦境 2024-12-14 03:03:15

请移至

[activityIndicatorTemp release];

addSubview之后:

[[self tableView] addSubview:activityIndicator];

please move

[activityIndicatorTemp release];

after addSubview:

[[self tableView] addSubview:activityIndicator];
甜味拾荒者 2024-12-14 03:03:15

这里的问题是当我设置活动指示器的位置时。我在初始化表视图之前就这样做了。

[activityIndicatorTemp setCenter:[[self tableView] center]];

我删除了上面的内容并且它起作用了。

The problem here is when I was setting the location of the activityindicator. I did this before the tableview had been initialized.

[activityIndicatorTemp setCenter:[[self tableView] center]];

I removed the above and it worked.

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