Home  >  Q&A  >  body text

ios - 将一个控制器的View添加到scrollView中,滑出屏幕为什么不走ViewDidDisapper方法?

将多个控制器的View添加到scrollView中,就第一次进入的时候会走ViewDidAppear方法,滑动屏幕为什么不走ViewDidDisapper或者ViewDidAppear方法?

PHP中文网PHP中文网2741 days ago615

reply all(4)I'll reply

  • PHP中文网

    PHP中文网2017-04-18 09:46:00

    If you directly add the view in the viewController to the view controlled by another controller using the addSubView method, in this case, because the view has left the control scope of the original controller, the callbacks related to the display and hiding of the view will not be available. It worked. It needs to be handled manually under the current controller, such as manually calling the viewDidDisappear method of the controller corresponding to that view when sliding the scrollView to a certain range, etc.

    It is recommended to use childViewController.

    reply
    0
  • ringa_lee

    ringa_lee2017-04-18 09:46:00

    Are you sure you don’t want to leave?

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 09:46:00

    Is this method done after the sliding is finished?

    reply
    0
  • PHPz

    PHPz2017-04-18 09:46:00

    Sliding the screen does not remove the controller and the views it controls. Of course it does not ViewDidDisapper

    reply
    0
  • Cancelreply