2

I used the code shown below to present a new view controller in a seamless sliding motion. The actual animation works perfectly but when the animation has finished, all of the views disappear and i am left with a blank screen. There is an error posted in the console saying

"Unbalanced calls to begin/end appearance transitions for < Rocket_Game18GameViewController: 0x155e288f0 >"

class SlideRightToLeft: UIStoryboardSegue {
override func perform() {
    var sourceVC:UIViewController = self.sourceViewController as UIViewController
    var destVC:UIViewController  = self.destinationViewController as UIViewController

    let sourceVCFrame = sourceVC.view.frame
    let width = destVC.view.frame.size.width
    sourceVC.view.addSubview(destVC.view)
    destVC.view.frame = CGRectOffset(sourceVCFrame, width, 0)

    UIView.animateWithDuration(1.5, delay: 0, options: UIViewAnimationOptions.CurveEaseInOut, animations: {
        sourceVC.view.frame = CGRectOffset(sourceVCFrame, -width, 0)
        }, completion: {
            finished in
            destVC.view.removeFromSuperview()
            sourceVC.presentViewController(destVC, animated: false, completion: nil)
        })
    }
}

Please ask if you need any more information, Thanks!

Jack Chorley
  • 2,309
  • 26
  • 28
  • 1
    You're not calling any of the child view controller methods (`willMoveToParentViewController:`, etc). – duci9y Jul 23 '14 at 18:33
  • Sorry, im very new to this and have adapted this code from a tutoiral online which has nothing like what you said, could you give me an example? – Jack Chorley Jul 23 '14 at 19:00
  • 1
    That'd be bad. You say that you are very new to this. If that's the case, I suggest staying away from view controller containment, it's an intermediate level topic. Start with something simpler. That said, Apple's documentation is a good place to find relevant sample code. – duci9y Jul 23 '14 at 19:01
  • I meant to say new to transitions not xcode and swift, but thanks for your help anyway. Ill go check out the documentation – Jack Chorley Jul 23 '14 at 19:05
  • This was the only documentation i could find and it is out of date as "presentModalViewController" is now deprecated. Any ideas? https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomSegues/CreatingCustomSegues.html – Jack Chorley Jul 23 '14 at 19:43
  • https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html – duci9y Jul 23 '14 at 19:45

1 Answers1

0

I have now figured out what i was doing wrong by converting someone else's objective-c code into swift. It turns out that my whole custom animation idea was wrong and when iOS7 was released, they changed how it was done. Here is the link to the blog where i found the solution incase anyone else would like to see it

https://github.com/jbradforddillon/TransitioningExample

Jack Chorley
  • 2,309
  • 26
  • 28