0

I'm new toiOS and I'm trying to put in a banner ad at the top but it's not working. I know this is a bad question but I honestly don't know so I need some help. Any help is greatly appreciated.

.h file

#import <UIKit/UIKit.h>
#import <iAd/iAd.h>
@interface withadViewController : UIViewController <ADBannerViewDelegate> {
ADBannerView *adView;
BOOL bannerIsVisible;
IBOutlet ADBannerView *banner1;
IBOutlet UITextField *textField1;
IBOutlet UITextField *textField2;
IBOutlet UILabel *label1;
}
@property (nonatomic, assign) BOOL bannerIsVisible;
-(IBAction)calculate;
-(IBAction)clear;
@end

and my .m file

@synthesize bannerIsVisible;
-(void)bannerViewDidLoadAd:(ADBannerView *)banner
{
if(!self.bannerIsVisible)
{
    [UIView beginAnimations:@"animateBannerOn" context:NULL];
    // banner is invisible now and moved out of the screen on 50px
    banner.frame = CGRectOffset(banner.frame, 320, 50);
    [UIView commitAnimations];
    self.bannerIsVisible = YES;
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
if (self.bannerIsVisible)
{ [UIView beginAnimations:@"animateAdBannerOff" context:NULL];
    // banner is visible and we move it out of the screen, due to connection issue
    banner.frame = CGRectOffset(banner.frame, 0, -320);
    [UIView commitAnimations];
    self.bannerIsVisible = NO;
}
}
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:         -(BOOL)willLeave
{
NSLog(@"Banner view is beginning an ad action");
BOOL shouldExecuteAction = YES;
if (!willLeave && shouldExecuteAction)
{
    // stop all interactive processes in the app
    // [video pause];
    // [audio pause];
}
return shouldExecuteAction;
- (void)viewDidLoad {
[super viewDidLoad];
adView = [[ADBannerView alloc]initWithFrame:CGRectZero];
adView.frame = CGRectOffset(adView.frame, 0, -50);
adView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
adView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.view addSubview:adView];
adView.delegate=self;
self.bannerIsVisible=NO;
[super viewDidLoad];    
@end
bryanmac
  • 38,941
  • 11
  • 91
  • 99
bob smith
  • 1
  • 1
  • 1
    Doesn't show the banner? This shouldn't even compile. – Mick MacCallum Aug 31 '13 at 00:23
  • @0x7fffffff maybe that's exactly why it doesn't show the banner? – Novarg Aug 31 '13 at 00:29
  • No, if this code was actually in your application as shown it wouldn't even let get to the point of running. –  Aug 31 '13 at 00:38
  • Assuming you have been getting to to work, is this a simulator specific issue or does it also occur when testing on an iPhone? You should look at http://stackoverflow.com/questions/5947552/how-to-display-test-iad-banner-in-the-simulator if it is simulator specific (and in general). – AdamG Aug 31 '13 at 01:16

0 Answers0