I building my first app in swift and created a custom segue so the slides of my storyboard are presented (sliding) from left to right. The code in my custom segue class, which I got from iOS Segue - Left to Right -, is below:
import UIKit
class SegueFromLeft: UIStoryboardSegue {
override func perform() {
let src = self.source
let dst = self.destination
src.view.superview?.insertSubview(dst.view, aboveSubview: src.view)
dst.view.transform = CGAffineTransform(translationX: -src.view.frame.size.width, y: 0)
UIView.animate(withDuration: 0.25,
delay: 0.0,
options: .curveEaseInOut,
animations: {
dst.view.transform = CGAffineTransform(translationX: 0, y: 0)
},
completion: { finished in
src.present(dst, animated: false, completion: nil)
}
)
}
}
I changed some of the segues in my storyboard to this custom segue. The segue connecting my initial view controller to a navigation controller which then connected to another view controller functions correctly. However, when a different segue is executed, the animation occurs, but the screen freezes immediately after.
This snapshot of my storyboard that shows the functioning and dysfunctional segues
After the simulator freezes, an error marks this line in the SegueFromLeft class :
src.present(dst, animated: false, completion: nil)
The error message states "Thread 1: EXC_BAD_ACCESS (code=2, address=0x7ffee5c39fb8)", which I believe has something to do with memory allocation, but don't know how to fix it or why it is occurring.
All help in alleviating this error is greatly appreciated.
Thanks!