mick1996
mick1996

Reputation: 606

Speed up segues and Unwind segues

I am trying to speed up segues and unwind segues between view controllers. If I am doing anything fundamentally wrong please let me know or if I need to upload more code for context.

Here is a youtube demonstration of what is wrong: https://www.youtube.com/watch?v=VZsAg0L-W5g&feature=youtu.be

Basically when I click 'View AR' it takes a little too long to go to the AR View Controller

Secondly when I try to unwind to the 'CollectionView Controller' it take again a little too long to unwind to the previous controller.

I also have to keep memory in mind as this is a very memory intensive application.

Any help is welcome!!!!

Here is the segue from first view controller:

@objc private func ViewAR(_ sender: UIButton) {
    imagesOne = nil
    imagesTwo = nil
    imagesThree = nil
    imagesFour = nil
    imagesFive = nil

    //goToAR
    self.performSegue(withIdentifier: "goToAR", sender: self)
}

As you can see above I set the images to nil for memory purposes then segue to the AR View controller

Here is the unwind segue from second view controller:

 @objc private func closeController(_ sender: UIButton) {
        DispatchQueue.main.async {
            self.sceneView.removeFromSuperview()
            self.performSegue(withIdentifier: "unwindToSwipe", sender: self)
        }
    }

Upvotes: 0

Views: 100

Answers (2)

mick1996
mick1996

Reputation: 606

Hey guys with help from the comments, I was able to learn that the problem is not with the segue, it is with the code itself.

I have to employ the use of code like viewWillAppear

Source: https://developer.apple.com/documentation/uikit/uiviewcontroller/1621510-viewwillappear

Upvotes: 0

Kudos
Kudos

Reputation: 1490

Stop using segues , Start using self.NavigationController.push(vc) This is indeed best way to navigate.

Upvotes: -3

Related Questions