十一岁的加重songxing10000…… ------ 回到博主首页

MBProgressHUD上传照片进度提示

第一步,控制器先来个属性

@property (strong, nonatomic) MBProgressHUD *HUD;

第二步,显示与隐藏的调用方法

- (void)hudTipWillShow:(BOOL)willShow{
    if (willShow) {
        [self resignFirstResponder];
        UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
        if (!_HUD) {
            _HUD = [MBProgressHUD showHUDAddedTo:keyWindow animated:YES];
            _HUD.mode = MBProgressHUDModeDeterminateHorizontalBar;
            _HUD.labelText = @"正在上传图片...";
            _HUD.removeFromSuperViewOnHide = YES;
        }else{
            _HUD.progress = 0;
            [keyWindow addSubview:_HUD];
            [_HUD show:YES];
        }
    }else{
        [_HUD hide:YES];
    }
}

第三步,上传前,让其显示

    [self hudTipWillShow:YES];

第四步,上传中,进度提示

if (self.HUD) {
            self.HUD.progress = progress;// progress是回调进度        
}

第五步,上传完毕,让其隐藏

[self hudTipWillShow:NO];

 

posted @ 2015-11-28 17:39  songxing10000  阅读(1384)  评论(0编辑  收藏  举报