ios 旋转器在停止命令后不停止

标签 ios xcode spinner

我有一个 ios 微调器,当我调用它时(当用户登录时),它会变得不隐藏并启动,并且如果使用代码成功或不成功,应该停止并返回到隐藏状态:

[spinner stopAnimating];

但是,由于某种原因,它一直在旋转,因此仍然不隐藏。我认为像这样简单的事情只需要“旋转器停止动画”方法...... (顺便说一下,我将旋转器命名为“spinner”)

最佳答案

就我而言,我这样做:

// on main thread
-(void)spinnerStopAnimating {
    if ([self.activityIndicatorView isAnimating]) {
        [self.activityIndicatorView stopAnimating];
    }
}

在这里,我通过以下方式初始化了我的事件指示器:

- (void)awakeFromNib
{
    activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    [self addSubview:self.activityIndicatorView];
}

并以这种方式开始:

CGRect rect = self.frame;
self.activityIndicatorView.center = CGPointMake(rect.size.width /2.0, rect.size.height / 2.0);

[self bringSubviewToFront:self.activityIndicatorView];
[self.activityIndicatorView startAnimating];

这还将微调器定位在 View 的中间。

关于ios 旋转器在停止命令后不停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13436931/

相关文章:

ios - UILocalizedIndexCollat​​ion 上的 `sectionForSectionIndexTitleAtIndex` 如何工作? (特别是带有自定义部分标题)它总是返回相同的数字

IOS:对齐 UILabel 中的文本在 UI 中不起作用

c++ - DCC fatal error F2588链接器错误代码:1($ 00000001)

ios - 如何在快速弹出 View Controller 后传递数据

android - ActionBar 中的多个微调器

android - 如何根据 android spinners 从 sqlite db 中选择的项目显示两个日期之间的数据?

android - 修改 Android Spinner 下拉部分的大小?

ios - UILabel 调整其 SuperView 的大小?

ios - XCode 和 Facebook IOS SDK - 说明不正确

ios - 使用未解析的标识符 'GMSServices'