-4

'removeChild' is inaccessible due to 'internal' protection level Extra argument 'in' in call

removeChild(bottomSheet)
addChild(bottomSheet, in: view)
hi1231bye
  • 1
  • 5

1 Answers1

0

That's not the method you are looking for. This is how you remove a child view controller from it's parent:

    viewController.willMove(toParent: nil)
    viewController.view.removeFromSuperview()
    viewController.removeFromParent()

It looks like you're trying to remove bottomSheet, so replace viewController in my code with that.

Oscar Apeland
  • 6,422
  • 7
  • 44
  • 92
  • Thank you!! It works, but what about addChild? it keeps giving me an in: is extra (btw the codes are in different lines, not related or in the same function) – hi1231bye Apr 05 '19 at 20:13
  • @hi1231bye Step 1: `addChild(yourViewController)`, Step 2: `view.addSubview(yourViewController.view)`, Step 3: `yourViewController.didMove(toParent: self)` – Oscar Apeland Apr 06 '19 at 13:41
  • All these lines should be ran from the parent view controller, the one you are adding the children to. – Oscar Apeland Apr 06 '19 at 13:42
  • Thank you so much!! But, do you happen to know why it's not showing up? I used OverlawContainer pods but my Xcode is not detecting it, it had a function called, addChild(_ child: UIViewController, in containerView: UIView) and inside it, it's similar to what you have except it has a child.view.pinToSuperview(), child being the viewController – hi1231bye Apr 06 '19 at 19:35