简体   繁体   中英

Custom segue without animation in Swift

I'm trying to make custom segue between two view controllers without any animation. Everything works as I expecting just console giving me following message:

2015-06-16 12:19:01.537 prototyp_2[42453:9048104] Unbalanced calls to begin/end appearance transitions for .

Here is my code:

class Segue_forward: UIStoryboardSegue {

    override func perform() {

        // zdroj a destinace do lokálních proměnných
        var firstVCView = self.sourceViewController.view as UIView!
        var secondVCView = self.destinationViewController.view as UIView!

        // rozměry displeje
        let screenWidth = UIScreen.mainScreen().bounds.size.width
        let screenHeight = UIScreen.mainScreen().bounds.size.height

        // initial position of destination view
        secondVCView.frame = CGRect(x: 0.0, y: 0.0, width: screenWidth, height: screenHeight)

        // protože destination VC není subview okna aplikace tak to musime napravit
        let window = UIApplication.sharedApplication().keyWindow
        window?.insertSubview(secondVCView, aboveSubview: firstVCView)

        // animace
        UIView.animateWithDuration(0.0, animations: { () -> Void in

            firstVCView.frame = CGRectOffset(firstVCView.frame, 0.0, 0.0)
            secondVCView.frame = CGRectOffset(secondVCView.frame, 0.0, 0.0)

        }) { (Finished) -> Void in

            self.sourceViewController.presentViewController(self.destinationViewController as! UIViewController, animated: false, completion: nil)

        }


    }

}

And here is my action:

@IBAction func nextQuestion(sender: AnyObject) {
   self.performSegueWithIdentifier("id_forwardSegue", sender: self)
}

Just do it without animation:

override func perform() {
    self.sourceViewController.presentViewController(self.destinationViewController as! UIViewController, animated: false, completion: nil)
}

展示新的UIViewController和parentViewController:

self.sourceViewController.parentViewController?.presentViewController(YOUR_VIEW_CONTROLLER, animated: false, completion: nil)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM