Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS view positioning bug
    text
    copied!<p>I'm having a strange issue with positioning some content (in this case Admob ads) in my app. My views are standard <code>UITableViewControllers</code> and I want to position the ads so they are anchored to the very bottom of the view (above the toolbar though).</p> <p>Here is the code I am using to place the ads (this is the delegate method required by the Admob SDK).</p> <pre><code>- (void)didReceiveAd:(AdMobView *)adView { // get the view frame //CGRect frame = self.navigationController.view.frame; CGRect frame = self.view.superview.frame; // put the ad at the bottom of the screen adMobAd.frame = CGRectMake(0, frame.size.height - 48, frame.size.width, 48); [self.view.superview addSubview:adMobAd]; } </code></pre> <p>This code works fine to initially place the ad, and the ad appears at the bottom of the screen where I want it. However, there are times that the ad will jump to the middle of the screen after certain user interactions. </p> <p>For instance, when a user selects and entry in the tableview and the next controller is loaded onto the navigation controller stack. When the user navigates back to the initial tableview controller where the ad resides, the ad will now be in the middle of the screen instead of the bottom.</p> <p>Or if the user selects a button that pops a new <code>modalViewController</code>, the same thing will happen when the <code>modalViewController</code> is dismissed.</p> <p>Am I anchoring the ad to the wrong place? Do I need to always reposition the ad when the view is loaded? What am I missing?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload