gpt4 book ai didi

ios - UITableView 和居中事件指示器 View

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:26:18 30 4
gpt4 key购买 nike

我有一个 UITableView,它从 Parse.com 获取数据。在执行此操作时,我想在居中的表格上方显示一个事件指示器。我的代码是:

        UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
indicator.center=self.view.center;
[self.view addSubview:indicator];
[indicator startAnimating];

但是它不是很重要:

enter image description here

抱歉图片太大了!我尝试将指标添加到表 superView 中,但没有任何区别。这一切有点菜鸟。有人可以给我一些指示,指出我可能做错了什么吗?

最佳答案

不不不。你不需要这些。您只需执行以下操作:

[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];

一旦您想将其关闭,请执行以下操作:

[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];

不要担心将指示器添加为 subview ,或者它的位置或大小。它是状态栏的一部分,由 Apple 负责,您无法更改其大小/颜色/等等...您可以打开和关闭它。

更新

哦,抱歉,我以为你在谈论 UIStatusBar 事件指示器。在回答您的问题时,为了使 UIActivityIndi​​catorView 居中,只需执行以下操作:

UIActivityIndicatorView *spinner = [[UIActivityIndicatorVIew alloc] 
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
CGRect frame = spinner.frame;
frame.origin.x = (self.view.frame.size.width / 2 - frame.size.width / 2);
frame.origin.y = (self.view.frame.size.height / 2 - frame.size.height / 2);
spinner.frame = frame;
[view addSubview:spinner];
[spinner startAnimating];

关于ios - UITableView 和居中事件指示器 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29600318/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com