Gintas_
Gintas_

Reputation: 5030

Transparent ViewController work with presentViewController, but not pushViewController

let dialog: FriendCheckInDialogViewController = storyboard?.instantiateViewControllerWithIdentifier("FriendCheckInDialogViewController") as! FriendCheckInDialogViewController
dialog.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContext

If I use

self.navigationController?.presentViewController(dialog, animated: false, completion: nil)

Then transparency works. But popToRootViewControllerAnimated does not, so I cannot go back.

If I use

self.navigationController?.pushViewController(dialog, animated: false)

Then background becomes black instead of transparent. But popToRootViewControllerAnimated works, so I can go back.

What should I do?

Upvotes: 1

Views: 318

Answers (1)

Paulw11
Paulw11

Reputation: 115002

You seem to be mixing different presentation styles.

If you present a view controller modally using presentViewController, then you can dismiss it using dismissViewController. In this case you can present the view controller modally over the current view controller.

If you push a view controller onto the navigation controller stack, then you can pop that view controller back off, but the pushed view controller replaces the current view controller, so you can't expose it "underneath".

Upvotes: 2

Related Questions