Search code examples
iosswift4uipageviewcontroller

when i call self.view.removeFromSuperview() on uipageviewcontroller then black screen shows up


I have page view controller and want to remove it and go back to homeviewcontroller, but when i call

self.view.removeFromSuperview()

it show black screen instead of remove it and go back to parent


Solution

  • You shouldn't use removeFromSuperView() on view controller views. Instead use self.dismiss(animated: true, completion: nil) if you presented it modally, or use navigationController?.popViewController(animated: true) if you pushed it.