Reputation: 1904
I am presenting a new ViewController through a storyboard. I am unsure of how do I show a progressHUD during the time it takes to present another ViewController.
My current approach
I am using SVProgressHUD and this is how I did it. The SVProgressHUD do not show up immediately when it is presenting another ViewController.
Main problem with approach
Progress bar is showing only at the end of the presentation of the ViewController instead of immediately.
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main",bundle: nil)
var destViewController : UIViewController!
switch (indexPath.row) {
case 0:
SVProgressHUD.show() // This shows the progress bar b
destViewController = mainStoryboard.instantiateViewControllerWithIdentifier("myViewController") as! UIViewController
break
Upvotes: 1
Views: 1112
Reputation: 14857
You can do it programmatically using
self.presentViewController(destViewController, animated: true) { () -> Void in
// After presentation finishes.
SVProgressHUD.dismiss() // dismiss HUD.
}
Upvotes: 1
Reputation: 129
To hide the progress view you can use the callback '-(void)prepareForSegue:sender:'. This method gets called on the view controller before a new view controller is about to be displayed.
Here is the API reference: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/#//apple_ref/occ/instm/UIViewController/prepareForSegue:sender:
Upvotes: 1