回答
创建:
spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[spinner setCenter:CGPointMake(kScreenWidth/2.0, kScreenHeight/2.0)]; // I do this because I'm in landscape mode
[self.view addSubview:spinner]; // spinner is not visible until started
开始:
[spinner startAnimating];
停止:
[spinner stopAnimating];
当您终于完成时,从视图中删除微调器并释放。
关于此的文档非常清晰。这是一个UIView子类,因此您可以像使用其他视图一样使用它。开始/停止使用的动画
[activityIndicator startAnimating];
[activityIndicator stopAnimating];
看看开放源代码的WordPress应用程序。他们有一个非常可重用的窗口,用于显示应用程序当前显示的任何视图顶部的“正在进行的活动”类型显示。
http://iphone.trac.wordpress.org/browser/trunk
你想要的文件有:
- WPActivityIndicator.xib
- RoundedRectBlack.png
- WPActivityIndicator.h
- WPActivityIndicator.m
然后要显示它使用类似:
[[WPActivityIndicator sharedActivityIndicator] show];
并与隐藏:
[[WPActivityIndicator sharedActivityIndicator] hide];
谢谢,我正在寻找的也是。请注意,WPActivityIndicator已被重命名(并重构)为WPProgressHUD(请参阅http://iphone.trac.wordpress.org/browser/trunk/Classes/WPProgressHUD.h)。 – 2009-07-19 06:00:27
sharedActivityIndicator在您的链接中找不到类methos方法。 – 2012-09-19 06:41:40
的问候:
看看开源WordPress应用。他们有一个非常可重用的窗口,用于显示应用程序当前显示的任何视图顶部的“正在进行的活动”类型显示。
请注意,如果您确实使用此代码,您必须将所有源代码提供给您自己的应用程序给任何请求它的用户。您需要意识到他们可能决定重新包装您的代码并将其在商店中出售。这一切都是在GNU通用公共许可证(GPL)的条款下提供的。
如果你不想被迫打开你的源代码,那么你不能使用wordpress iphone应用程序中的任何东西,包括引用的活动进度窗口,而不会强制GPL应用到你自己的应用程序中。
我认为你应该使用隐藏更好。
activityIndicator.hidden = YES
使用Storyboard-
Create-
- 转到main.storyboard(这可以在theProject导航发现您的Xcode的左侧)并从对象库中拖放“活动指示器视图”。
转到头文件,并创建一个IBOutlet为UIActivityIndicatorView-
@interface ViewController : UIViewController @property (nonatomic,strong) IBOutlet UIActivityIndicatorView *activityIndicatorView; @end
建立从奥特莱斯到UIActivityIndicatorView的连接。
开始:
使用下面的代码时,你需要在实现文件中使用下面的代码来启动活动的指标(.M) -
[self.activityIndicatorView startAnimating];
停止:
当需要使用followi停止活动指示器时,请使用以下代码在实现文件NG代码(.M) -
[self.activityIndicatorView stopAnimating];
活动指示灯2秒显示,进入下一页
@property(strong,nonatomic)IBOutlet UIActivityIndicator *activityindctr;
-(void)viewDidload { [super viewDidload];[activityindctr startanimating]; [self performSelector:@selector(nextpage) withObject:nil afterDelay:2];}
-(void)nextpage{ [activityindctr stopAnimating]; [self performSegueWithIdentifier:@"nextviewcintroller" sender:self];}
- (IBAction)toggleSpinner:(id)sender
{
if (self.spinner.isAnimating)
{
[self.spinner stopAnimating];
((UIButton *)sender).titleLabel.text = @"Start spinning";
[self.controlState setValue:[NSNumber numberWithBool:NO] forKey:@"SpinnerAnimatingState"];
}
else
{
[self.spinner startAnimating];
((UIButton *)sender).titleLabel.text = @"Stop spinning";
[self.controlState setValue:[NSNumber numberWithBool:YES] forKey:@"SpinnerAnimatingState"];
}
}
- 1. Monotouch - 使用按钮上的活动指示器视图TouchDown
- 2. 活动视图指示器在LaunchScreen.storyboard上没有动画
- 3. iPhone:何时应该使用网络活动指示器
- 4. 在swift 2.0中显示活动指示器3秒表视图
- 5. 如何使用图像而不是活动指示器?
- 6. iPhone SDK - WebView活动指示器
- 7. iPhone活动指示灯
- 8. 活动指示灯不iphone
- 9. 在webview上添加活动指示器
- 10. 如何显示活动指示器
- 11. 无法获取要在iPhone应用上显示的活动指示器
- 12. (Iphone Sdk)如何在视图控制器加载时显示动画活动指标?
- 13. MVVM活动指示器在视图模型
- 14. 如何显示活动指示器视图,直到函数完全执行?
- 15. 活动指示器IOS使用问题
- 16. 活动指示灯未显示在iPhone上
- 17. 如何显示活动指标,而在视图控制器之间传递
- 18. (iphone)在重新更新UI之前显示活动指示器
- 19. 如何在滚动视图之前加载活动指示器甚至出现在我的屏幕上?
- 20. 活动指标视图
- 21. UIButton上的活动指示器
- 22. 如何在钛sdk-iPhone中对齐网页视图活动指标中心?
- 23. 如何为集合视图创建活动指示器。详见后文
- 24. 如何让我的活动指示器视图覆盖所有屏幕?
- 25. 使用ASIHTTPREQUEST库发送同步请求,显示iPhone中的活动指示器
- 26. UITableView与活动指示器
- 27. AKSwiftSlideMenu活动指示器
- 28. 在iPhone SDK中创建自定义活动指示器?
- 29. Iphone活动指示器在导航栏中间
- 30. Nativescript:如何隐藏滚动视图上的滚动指示
我发现[MBProgressHUD](https://github.com/jdg/MBProgressHUD),它提供了一个不错的模式指示器。这很容易实现。 – foz 2011-01-13 21:08:38