0

So, I am trying to implement iAds into my application, but I cannot get it to work properly.

I am using these two functions to show and hide the banner and it works great:

- (void)showAdBanner:(ADBannerView *)banner {
    if (bannerVisible) return;
    NSLog(@"showing ad");
    [UIView beginAnimations:@"animateBannerIn" context:nil];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [banner setFrame:CGRectOffset([banner frame], 0, -bannerHeight)];
    [toolbarView setFrame:CGRectOffset([toolbarView frame], 0, -bannerHeight)];
    [UIView commitAnimations];
    bannerVisible = YES;
}

- (void)hideAdBanner:(ADBannerView *)banner {
    if (!bannerVisible) return;
    NSLog(@"hiding ad");
    [UIView beginAnimations:@"animateBannerOut" context:nil];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [banner setFrame:CGRectOffset([banner frame], 0, bannerHeight)];
    [toolbarView setFrame:CGRectOffset([toolbarView frame], 0, bannerHeight)];
    [UIView commitAnimations];
    bannerVisible = NO;
}

The only issue is that after one presses on the iAd banner, the toolbar view returns to its original position sans-iAd.

I have removed all layout constraints and it still is occurring. I can attach a video after if it clarifies.

Thank you

Video: https://www.dropbox.com/s/64mbiowk94sl6rq/iAdIssue.mov

rmaddy
  • 314,917
  • 42
  • 532
  • 579
AKrush95
  • 1,381
  • 6
  • 18
  • 35
  • Try disabling `Autolayout` on the entire view. (go to xib > select the main view > uncheck `Use Auto Layout` – staticVoidMan Dec 12 '13 at 18:51
  • @staticVoidMan wouldn't that remove ALL of my constraints, though? – AKrush95 Dec 12 '13 at 19:09
  • @AKrush95: Yes, it would. – Linuxios Dec 12 '13 at 19:12
  • yes it surely would. if you want to keep autolayout then you need to manage your constraints better. link: http://kingscocoa.com/tutorials/autolayout-animations/ – staticVoidMan Dec 12 '13 at 19:12
  • @staticVoidMan So disabling `Autolayout` worked, but now I don't know how I'll have my bottom bar automatically adjust to the 3.5" device. Also, failed to open the link. – AKrush95 Dec 12 '13 at 19:15
  • look into `Autosizing` options. you know... `struts and springs`. i love that for simple designs. link: http://msmvps.com/blogs/kevinmcneish/archive/2012/12/10/tutorial-ios-6-auto-layout-versus-springs-and-struts.aspx. example: for bottom bars to always be at the bottom on any screen size, u enable the bottom strut and one of the side struts (_doesn't matter_) – staticVoidMan Dec 12 '13 at 19:16
  • I've been using struts and springs already. My bottom bar would stay in place regardless of the size or orientation. I just have this new issue where I guess I have to modify the constraint. The auto layout animations link code doesn't seem to work for me. – AKrush95 Dec 12 '13 at 19:25
  • yeah, `Autosizing` is a bit limited in this perspective. `Autolayout` is more flexible. Had you set a constraint on the bottom bar with respect to the iAd view? You must have. check - http://stackoverflow.com/questions/13296232/ios-how-does-one-animate-to-new-autolayout-constraint-height – staticVoidMan Dec 12 '13 at 19:36
  • Okay. So I have the iAd constrained to the bottom, and the bar constrained to the iAd. I'm trying to figure out animation by using addConstraint, but it's not working out too well. If I can figure that out, that would be my solution. – AKrush95 Dec 12 '13 at 19:46

0 Answers0