JamesG
JamesG

Reputation: 1601

Swift Reload CurrentView

I am trying to reload the current view controller.

All the examples I can find, are for either pull to refresh or how to reload a tableview.

I have used SwiftSpinner (https://github.com/icanzilb/SwiftSpinner) in my project. When I use:

SwiftSpinner.show("Please connect to the internet, and try again").addTapHandler({
 SwiftSpinner.hide({
      print("Closed")
 })
}, subtitle: "Tap to try again..")

When the user taps the view to close the spinner, I get Closed in the Console.

I have tried changing that print to:

self.loadView()

However this does not do anything.

How do I get the view to reload?

Upvotes: 1

Views: 811

Answers (1)

MarkP
MarkP

Reputation: 2566

As far as I know you cannot 'reload' the viewController (Please correct me if I am wrong).

What are you trying to reload? Is it something specifically? It looks like you are checking for internet connection, right?

What I reccommend is, in your viewDidLoad take everything out and put it in a function, for example stuffToLoad()

Then, call that function in your ViewDidLoad. Run the app, does everything still work the way it is supposed to? If so that means you can now use:

SwiftSpinner.show("Please connect to the internet, and try again").addTapHandler({
   SwiftSpinner.hide({
      self.stuffToLoad()
 })
}, subtitle: "Tap to try again..")

Upvotes: 2

Related Questions