问题
I'm using the standard setup procedure for Mobclix
in an iOS
app and I'm calling the requestAndDisplayAdFromViewController:
method from within viewWillAppear:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[fullScreenAdViewController requestAndDisplayAdFromViewController:self];
}
here's the warning I'm getting:
Warning: Attempt to present <MobclixFullScreenAdViewController: 0x14f2c0> on <EditGameViewController: 0x1838d0> whose view is not in the window hierarchy!
I hope that's enough to go on. thanks for any help.
回答1:
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.
回答2:
Try to move your code [fullScreenAdViewController requestAndDisplayAdFromViewController:self];
to viewDidAppear
.
回答3:
You can also try to display the view in the viewDidLoad method.
回答4:
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
来源:https://stackoverflow.com/questions/15659526/how-to-fix-the-warning-view-is-not-in-the-window-hierarchy