------<a href="http://www.itheima.com" target="blank">Java培训、Android培训、iOS培训、.Net培训</a>、期待与您交流! -------
------<a href="http://www.itheima.com" target="blank">Java培训、Android培训、iOS培训、.Net培训</a>、期待与您交流! -------
1.前言
我们有时候会等待手机的响应,像刷新微博啊,刷新空间啊,如果这个刷新的操作不能通过一个可视化的控件和用户交互的话,我相信用户是不会愿意使用这款软件的。用来消除用户的心里等待时间。
2.活动指示器介绍
我们刷新空间的时候,会发现有个东西在转啊转,这
个控件叫做ActivityIndicatorView。
新建工程ActivityIndicatorView
进入ActivityIndicatorView这个类可以看到这几个方法
根据英文我们很容易知道这个函数干嘛的
接下来我们来实现这个控件的旋转
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *activity;
- (IBAction)refresh:(id)sender;
@end
- (IBAction)refresh:(id)sender {
//判断活动指示器是否在旋转
if(_activity.isAnimating){
//如果旋转点击按钮则停止旋转
_activity.stopAnimating;
}else
3.进度条ProgressView介绍
下载的时候,我们用什么来知道我们下载了百分之多少呢?我们可以通过进度条这个控件。
代码如下:
- (IBAction)downloadProgress:(id)sender
{
myTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(download)
userInfo:nil
repeats:YES];
}
-(void)download{
self.myProgressView.progress=self.myProgressView.progress+0.1;
if (self.myProgressView.progress==1.0) {
[myTimer invalidate];
UIAlertView*alert=[[UIAlertView alloc]initWithTitle:@"download completed!"
message:@""
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[alert show];
}
}