Hello, I have been trying to show the activityIndicator I have set up before the segue to another viewController. When I tap the button for segue, the app gets into the inactive state for at least 5 seconds. I'm aiming to show the activityIndicator before the view freezes. There is no problem with the setup of the activityIndicator. The problem I'm having is the activityIndicator shows up after the segue on the other viewController. Thanks in advance.
import UIKit
class StitchEffectViewController: UIViewController {
// @IBOutlet weak var activityIndicator: UIActivityIndicatorView!
let stitchPhotoID = "StitchPhotoID"
@IBOutlet weak var tapAboveOutlet: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// activityIndicator.isHidden = true
// activityIndicator.hidesWhenStopped = true
}
// override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
// super.viewWillTransition(to: size, with: coordinator)
//
// if UIApplication.shared.applicationState == .inactive {
// Spinner.update()
// }
//
// }
@IBAction func tapAbove(_ sender: UIButton) {
Spinner.start(style: .large, backColor: UIColor.white, baseColor: UIColor.green)
spinnerSetup()
}
func spinnerSetup() {
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0, execute: {
self.performSegue(withIdentifier: self.stitchPhotoID, sender: nil)
})
}
}
Problem comes probably from how you defined the segue.
you should not have a segue and an IBAction for the same button.
If so:
- remove the segue from the button
- create a PresentModally segue from the VC (control drag from the button at the top left over the VC view)
- Name it StictchPhotoID