1

I want to move PlayVideoViewController to the top of other view controllers like the picture. Please help!!!!!

enter image description here

6
  • share some code that you've written Commented Feb 1, 2018 at 9:37
  • I would suggest to describe the problem and the reason why would you do that. Commented Feb 1, 2018 at 9:38
  • playerVideoViewController = UIStoryboard(name: "PlayVideo", bundle: nil).instantiateViewController(withIdentifier: "playVideoSBID") as? PlayVideoViewController self.view = playerVideoViewController?.view self.window?.makeKeyAndVisible() self.window?.addSubview(self.view!) self.window?.bringSubview(toFront: self.view!) Commented Feb 1, 2018 at 9:38
  • I wrote that in app delegate. I do it because I want to make a floating view controller like youtube Commented Feb 1, 2018 at 9:39
  • When I perform segue to open another view controller it hide that my playvideo view controller Commented Feb 1, 2018 at 9:40

1 Answer 1

2

You could add a new view controller and set it as a child view controller. You can create a container view in which that controller will be added.

self.childViewControllers.first?.view.removeFromSuperview()
self.childViewControllers.first?.removeFromParentViewController()
self.containerView.addSubview(controller.view)
self.addChildViewController(controller)

Do remember to add a container view

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.