2

I'm having an issue with the setContainerView, the progress is not showing at all when I assign it to a custom view. I've tried everything with my UIView which is perfectly fine, but the progress remains invisible.

I've used it for a while now and had no problems without custom container views.

Any ideas ?

EDIT

For exemple, this is working (progress showing):

func download() {
    SVProgressHUD.show()
    User.downloadAllUsers { (user) in
        //Doing things
        DispatchQueue.main.async {
            //Updating UI
            SVProgressHUD.dismiss()
        }
    }
}

But this is not working (progress is not showing)

func download() {
    SVProgressHUD.setContainerView(loadingContainerView)
    SVProgressHUD.show()
    User.downloadAllUsers { (user) in
        //Doing things
        DispatchQueue.main.async {
            //Updating UI
            SVProgressHUD.dismiss()
        }
    }
}
Skaal
  • 1,016
  • 10
  • 10
  • one thought - while SVProgressHUD was absolutely amazing back in the day: it is perhaps fair to say that there is not a lot of need to use it any more. iOS has really moved on dramatically. – Fattie Jul 10 '17 at 13:01
  • add tried code and call it background – karthikeyan Jul 10 '17 at 13:02
  • @Fattie Do you mean that it's deprecated ? Or that better libraries exists now ? – Skaal Jul 10 '17 at 13:03
  • @karthikeyan I'm already calling it background, see my edit, I don't understand why it doesn't work when I change the view to my custom view. – Skaal Jul 10 '17 at 13:24
  • I mean it's not even in Swift right @skaal ? Here's **one of own my posts** on SVProgressHUD from the very old days - https://stackoverflow.com/a/23056076/294884 . These days you have storyboard references, I'd just pop a new view controller on top of the screen, you know? – Fattie Jul 10 '17 at 13:25
  • Well, written in objective C doesn't mean it's old, I'm also using Lottie, a powerful tool released by AirBnB early 2017 which is wrote in objective-C, so I don't get why you say it's deprecated. – Skaal Jul 10 '17 at 13:31
  • Hi @Skaal. It is not deprecated. It is rather pointless now that iOS has container views - it is 1000x easier to just use a container view. *And* iOS now has storyboard references, you can pop a new view on top with one line of code (well, a couple!) We used to use SVProgressHUD constantly as a core element of iOS work, but it's day is passed - it just adds pointless complication now (as you can see). – Fattie Jul 10 '17 at 13:45
  • @Fattie You mean that you're not using loaders anymore ? Only displaying views on top of others views while loading datas ? – Skaal Jul 10 '17 at 13:48
  • hi @Skaal I'm not sure what you mean by "Loaders" - ? Regarding "displaying views on top of others views" every single thing in iOS is a matter of "displaying views on top of others views". When I want to bring up a "spinner" or thermometer, yes, I simply use a container view, or nowadays you can just use storyboardID to instantiate anything from anywhere. pretty much every single thing in an iOS app is now a container view, it's just the basic way you make apps. So if you have a screen with five controls, knobs, lists or whatever - they're all just container views.... – Fattie Jul 10 '17 at 14:35
  • ... and sure if you need a "thermometer" over the top, i just use a container view (or as I say, just instantiate it from a storyboardID - then you can use the same one anywhere easily). intro to containerViews from back a few years when they became the main way to make iOS apps .. https://stackoverflow.com/a/23403979/294884 – Fattie Jul 10 '17 at 14:36
  • just for clarity for anyone googling, the call "setContainerView" which is part of the old SVProgressHUD package, has absolutely no connection to ordinary "container views" in iOS. – Fattie Jul 10 '17 at 14:38
  • Thanks a lot for your precisions @Fattie, as you mentionned, I'll explore the container's way instead of spinners in my app. I was already using it but not for displaying other views while my datas were loading. – Skaal Jul 10 '17 at 15:07
  • maybe it will help somehow ! – Fattie Jul 10 '17 at 17:58

1 Answers1

2

Purely FWIW, in your sample code, I think you're dismissing at the end of each operation rather than at the end of all operations ... I believe.

You'd probably use there a DispatchGroup as the solution.

A quick tutorial on using DispatchGroup would be beyond the scope of this QA.

Fattie
  • 30,632
  • 54
  • 336
  • 607