黑马程序员---ios等待相关的控件

------<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];
    }
    
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值