Ios UIActivityIndicatorView停止旋转

Ios UIActivityIndicatorView停止旋转,ios,objective-c,xcode,uitableview,uiactivityindicatorview,Ios,Objective C,Xcode,Uitableview,Uiactivityindicatorview,我的经验是,当我添加一个UIActivityIndicatorView作为我的UITableViewCells之一的子视图时,它只会旋转一小段时间,然后停止。有人知道为什么吗 原则上,这就是我在代码中所做的: - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView

我的经验是,当我添加一个
UIActivityIndicatorView
作为我的
UITableViewCell
s之一的子视图时,它只会旋转一小段时间,然后停止。有人知道为什么吗

原则上,这就是我在代码中所做的:

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyCell" forIndexPath:indexPath];

    if (indexPath.row == 0) cell.accessoryView = spinner;

    UILabel *label = (UILabel *)[cell viewWithTag:1];
    label.text = @"Some text";

    return cell;
}
其中
spinner
是一个
IBOutlet

IBOutlet UIActivityIndicatorView *spinner;

您需要手动启动和停止UIActivityIndicatorView的动画。 代码示例

将此添加到要开始动画的位置:

[spinner startAnimating];
[spinner stopAnimating];
将此添加到要停止动画的位置:

[spinner startAnimating];
[spinner stopAnimating];

希望这有帮助

尝试将其插入函数中

[spinner startAnimating];

如果要停止,请调用stopAnimating方法。

何时旋转活动指示器?无论是在tableview中加载数据还是在加载数据之前?我认为在我的故事板中选中微调器的动画复选框对应于
[spinner startAnimating]
-这也是因为它在开始时确实在旋转!嗯,直接在我的代码中插入一个
[spinner startAnimating]
实际上使它永远旋转!谢谢!:)当T Chad首先回答时,我不得不接受他的回答。我认为在我的故事板中选中旋转器的动画复选框对应于
[spinner startAnimating]
-也因为它在一开始就在旋转!嗯,直接在我的代码中插入一个
[spinner startAnimating]
实际上使它永远旋转!谢谢!:)