How to fix the warning: view is not in the window hierarchy

前端 未结 4 614
闹比i
闹比i 2021-01-29 07:19

I\'m using the standard setup procedure for Mobclix in an iOS app and I\'m calling the requestAndDisplayAdFromViewController: method from

相关标签:
4条回答
  • 2021-01-29 07:25

    You're calling it from viewWillAppear - at this point, the view is not necessarily in the hierarchy yet (it WILL appear, doesn't mean it has appeared yet). Try calling it from viewDidAppear, which is called when the view is confirmed to be in the hierarchy.

    0 讨论(0)
  • 2021-01-29 07:29

    You can also try to display the view in the viewDidLoad method.

    0 讨论(0)
  • 2021-01-29 07:34

    You should try moving this code to viewDidAppear.

    From the Apple documentation on viewWillAppear:

    This method is called before the receiver’s view is about to be added to a view hierarchy
    
    0 讨论(0)
  • 2021-01-29 07:43

    Try to move your code [fullScreenAdViewController requestAndDisplayAdFromViewController:self]; to viewDidAppear.

    0 讨论(0)
提交回复
热议问题