Swift: using UIModalTransitionStyle.flipHorizontal shows a black view

211 Views Asked by At

I'm trying to implement UIModalTransitionStyle.flipHorizontal and it works but it shows just a black view. here is my code:

@IBAction func loadNextView(_ sender:UIButton){

    let nextVC = NextViewController()
    nextVC.modalTransitionStyle = UIModalTransitionStyle.flipHorizontal
    self.present(nextVC, animated: true, completion: nil)
}

Any of you knows why it shows a black view? or how can show the correct view?

I'll really appreciate your help

2

There are 2 best solutions below

2
Shehata Gamal On

You need to load the VC like this [ nextID is it's id in storyboard ]

let nextVC  = self.storyboard?.instantiateViewController(withIdentifier: "nextID") as! NextViewController
2
Xchord On

Try setting the presented view controller's modalPresentationStyle to overCurrentContext:

nextVC.modalPresentationStyle = .overCurrentContext