iOS获取基于ASIHTTP的上传数据的变化方法

来源:互联网 发布:postgresql 数组查询 编辑:程序博客网 时间:2024/05/16 01:03

1、上传百分比

//累加的已上传百分比-(void)setProgress:(float)newProgress{    if (newProgress>=1) {//        [self.showShangChuanView removeFromSuperview];    }    self.progressIndicateLabel.text = [NSString stringWithFormat:@"已上传%2.f%%,还剩%2.f%%",newProgress*100,100 - newProgress * 100];    self.progressIndicateLabel.textColor = [UIColor whiteColor];    self.progressIndicateLabel.font = [UIFont systemFontOfSize:14];    self.progressIndicateLabel.frame = CGRectMake(20,100, 180, 40);    [self.indicateBGImageView addSubview:self.progressIndicateLabel];    progressView.progress = newProgress;    NSLog(@"进度 = %f",newProgress);}

2、上传速度

//不累加的每次上传数据量-(void)request:(ASIHTTPRequest *)request didSendBytes:(long long)bytes{    //    NSLog(@"every up");    NSLog(@"上传%2.fkb",(bytes/1024.f));}//累加的数据已上传总量-(void)request:(ASIHTTPRequest *)request incrementUploadSizeBy:(long long)newLength{    NSLog(@"累加上传总量 = %lld",newLength/(1024*1024));}


0 0
原创粉丝点击