0
votes

I'm having an issue with MBProgressHUD, I'm using it with SDWebImage. so actually as a function its working well.and what i do, is to the show progress and when its done show the image and hide the progress.

But sometimes the image shows and the progress is like 80 percent loading and then it hangs and never hides the progress,so i have to navigate back out of the controller to fix it.

HUD = MBProgressHUD(view: self.view)
        self.view.addSubview(HUD)
        HUD.mode = MBProgressHUDMode.AnnularDeterminate
        HUD.delegate = self
        HUD.show(true)

        let block: SDWebImageCompletionBlock! = {(image: UIImage!, error: NSError!, cacheType: SDImageCacheType, imageURL: NSURL!) -> Void in
            //          println(self)
            self.HUD.hide(false)
            self.HUD.removeFromSuperViewOnHide = true
        }

        cell.imageView.sd_setImageWithURL(url, placeholderImage: nil, options: nil, progress: { (value1, value2) -> Void in

            dispatch_async(dispatch_get_main_queue(), {
            var progress = Float(value1)/Float(value2)
            self.HUD.progress = progress

            })

        }, completed: block)
1

1 Answers

0
votes

You should use MBPRogressHUD factory, this will simplify the usage:

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.delegate = self
hud.mode = MBProgressHUDMode.AnnularDeterminate

Not sure it's totally linked to your problem, but then you should make sure also that the callback is called (so put logs for instance), it might not be the fault of the library.

Lastly, it's recommended to use lowercase letter for variables (hud instead of HUD), uppercase are usually reserved for constants.