Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to destroy instance of view controller after performing segue

I use performSegueWithIdentifier to navigate between views controllers

I have a tableView with multiple rows, when a row is actioned, i call a webViewController to play selected ressource with segue

performSegueWithIdentifier("Play", sender: nil)

Associate with :

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if(segue.identifier == "Play") {
        let detailVC = segue.destinationViewController as! WebViewController
        detailVC.courseToPlay = self.courseToPlay
    }
}

And, on WebViewController, i've a button to goBack on the list, whose i want to destroy instance of webViewController on goBack

I've not NavigationController in my storyBoard, so, this line doesn't work

navigationController.popViewControllerAnimated(true)

I use segue again to goBack :

performSegueWithIdentifier("closePlayer", sender: nil)

But each segue action instance a new view controller and they're never really free from memory, they seems to just be hiddens

eg : in Safari debugger i can see a lot of page and i can always interact with these in console

How to properly 'destroy' a view when scene change

like image 369
Khorwin Avatar asked Dec 15 '22 08:12

Khorwin


1 Answers

Swift3:

self.dismiss(animated: true, completion: nil)

Hope it can help you.

Thanks

like image 186
Sour LeangChhean Avatar answered Apr 29 '23 17:04

Sour LeangChhean