iOS Looking to delay segue between view controllers when button is pressed

Viewed 3168

I am fairly new to swift and Objective C, and I have an app that goes from the main view controller to the second view controller on a button press. THe second view controller opens up a camera and every time I click the button there is somewhat of a lag in the camera opening. I reckon this has something to do with the thread and how the process is being handled.

I want to introduce a delay between when my button on the first view controller is placed and when the second viewcontroller is displayed on the screen. Is there a delay that can be applied this way?

Here is the code to my main view controller with the button:

import UIKit

class ViewController: UIViewController {

    @IBAction func itemAction(_ sender: AnyObject) {
        performSegue(withIdentifier: "segue", sender: self )
    }

    @IBAction func logosAction(_ sender: Any) {
        performSegue(withIdentifier: "segue2", sender: self )
    }

    @IBOutlet var itemsButton: UIButton!

    @IBOutlet var carsButton: UIButton!


    override func viewDidLoad() {
        super.viewDidLoad()

        itemsButton.layer.cornerRadius = 10
        itemsButton.clipsToBounds = true

        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

Thank you!

2 Answers
Related