Let\'s say I have 3 view controller labeled \"A\",\"B\" and \"C\". Right now, \"A\" is the rootViewController of the window and it presents \"B\" modally when a button is ta
It seems that it is not possible to go from B to C without showing A briefly, which looks unprofessional. However, you can put a black subview over top of A until you've animated to C.
In Swift 3:
class A : UIViewController {
...
func showB() {
// Adding the black view before dismissing B does not work;
// the view is not displayed.
let black = UIView()
black.backgroundColor = UIColor.black
black.frame = self.view.bounds // assumes A is not zoomed
let b = B()
self.present(b, animated:true, completion: {
self.view.addSubview(black)
})
// Note: self.present() will start the animation,
// then b.imDone will be set. It is done here for
// clarity of what happens next, as if it were all
// one function.
b.imDone = {
b.dismiss(animated:false, completion: {
self.present(C(), animated:true, completion: {
black?.removeFromSuperview()
})
})
}
}
}
class B : UIViewController {
var imDone : (() -> Void)?
...
func f()
{
imDone?()
}
...
}
class C : UIViewController
{
...
}