Willem Massoels
Willem Massoels

Reputation: 41

Swift - dismiss last View Controller after manual transition

I'm building an app, where after 8 seconds of silence a new View Controller is pushed. The transition is cross dissolve (modally).

The new view controller has a blur effect and still shows the last View Controller. And you got it, I just don't have a clue how to dismiss the last one.

How do I do it?

// the code is really simple.

override func viewDidLoad() { super.viewDidLoad()

    NSTimer.scheduledTimerWithTimeInterval(8, target: self, selector: Selector("refreshApp"), userInfo: nil, repeats: false)

    // Do any additional setup after loading the view.
}

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

func refreshApp (){
    self.performSegueWithIdentifier("refreshIdentifier", sender: self)
}

Upvotes: 0

Views: 302

Answers (1)

Alessandro Ornano
Alessandro Ornano

Reputation: 35392

Try this code:

func refreshApp (){
        self.dismissViewControllerAnimated(true, completion: {
           self.performSegueWithIdentifier("refreshIdentifier", sender: self)
        })
}

Upvotes: 0

Related Questions