Search code examples
iosswiftbuttonseguecompletion

Do something on button tap then segue to another view controller


I turned an image into a UIgesturerecognizer so that I can press it like a button. When I press it I want it to segue out, but the next view loads a camera so I'm getting kind of a freeze while it's loading. I can't really run an activity indicator because it's going between view controllers. So I made a label that says "please wait..." and I set it to appear on the button press before the segue. The problem is that it isn't actually appearing because the freeze is happening before it actually shows up. Then on the new vc you briefly see it flash, so it is appearing but not quick enough to be efficient. How can I make the label appear, then begin the segue? This is the code right now

@IBAction func buttonTapped(sender: AnyObject) {
    //I want this label to show up before the segue starts happening
    self.loadingLabel.hidden = false
    //Segue       
    self.performSegueWithIdentifier("profilePicCamera", sender: self)
}

Solution

  • Call your camera load function from the viewDidAppear method.