iOS iad not working right?

johnnyfla123

macrumors newbie
Original poster
Jun 15, 2013
21
0
Alright so this is my last problem for some reason someone at apple decided to name iad and ipad. google thinks iad is ipad and its rubbish....

I checked the search button here but i couldn't find the problem i am having. I have my app ready to go for the most part everything is functional. I am using a tab bar type app that does not use storyboard. I am applying iads to both firstviewcontroller and the secondviewcontroller. The firstviewcontroller doesn't even load the iad and the second one loads it but it wont place its 380 it places it at the top no matter what when it loads. half the time iad doesn't even initiate. here is the snippets / screenshots.

i added this in both .m files to allow it to load or not load.
Code:
- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
    NSLog(@"bannerViewDidLoadAd");
    
    if (!self.bannerIsVisible)
    {
        [UIView beginAnimations:@"animateAdBannerOn" context:NULL];
        banner.frame = CGRectOffset(banner.frame, 0, 380);
        [UIView commitAnimations];
        self.bannerIsVisible = YES;
    }
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
    NSLog(@"bannerViewRecievedError");
    if (self.bannerIsVisible)
    {
        [UIView beginAnimations:@"animateAdBannerOff" context:NULL];
        banner.frame = CGRectOffset(banner.frame, 0, -380);  
        [UIView commitAnimations];
        self.bannerIsVisible = NO;
    }
}
this is the other .m part in both:
Code:
- (void)viewDidLoad {
    [super viewDidLoad];
    adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
    adView.frame = CGRectOffset(adView.frame, 0, -380);
    [self.view addSubview:adView];
    adView.delegate=self;
    self.bannerIsVisible=NO;
and the .h part. the ad part is also in both exactly the same:
Code:
#import <UIKit/UIKit.h>
#import <iAd/iAd.h>

@interface SecondViewController : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource, ADBannerViewDelegate>{
    
    ADBannerView *adView;
    BOOL bannerIsVisible;
	IBOutlet UITextField *billTotal;
    IBOutlet UILabel *profitAmount;
	IBOutlet UIPickerView *profitPicker;
	NSMutableArray *pickerViewArray;
	float profitSelected;
    
}

@property (nonatomic,assign) BOOL bannerIsVisible;
@property (nonatomic,retain)  IBOutlet UITextField *BillTotal;

@end

380 is at the bottom of the screen right above the tab bar as seen in the screen shots the first view nothing it jsut gives me "bannerViewDidLoadAd" and shows no ad. then in the other one if it loads it loads at the top if it doesn't load it also gives "bannerViewDidLoadAd."

it is set to make the ad windows on start up i see in xcode their is a ad windo i can use but then if theirs no ad the window stays there and i heard apple hates it.

I also read that that you must include the 2 functions to hide the ad when their is no ad so apple wont reject the app. Im not sure what to do but ill keep playing withit and hopefully it works :)


edit: when i did use the xcode window that you drag into the .xib files it would load an ad in both controllers but it wouldn't hide the ad if their wasn't an add so i tried this method.
 

Attachments

Last edited:

dejo

Moderator
Staff member
Sep 2, 2004
15,981
447
The Centennial State
Where do you think the following code, from your viewDidLoad, places the ad?:
Code:
adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.frame = CGRectOffset(adView.frame, 0, -380);
Also, please explain what animation effect you are trying to achieve when showing/hiding the ad banner.

And, have you thought about used block-based animation instead of beginAnimations:/commitAnimations?
 

johnnyfla123

macrumors newbie
Original poster
Jun 15, 2013
21
0
Where do you think the following code, from your viewDidLoad, places the ad?:
Code:
adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.frame = CGRectOffset(adView.frame, 0, -380);
Also, please explain what animation effect you are trying to achieve when showing/hiding the ad banner.

And, have you thought about used block-based animation instead of beginAnimations:/commitAnimations?

see im not entirely sure that im even doing it right because form various guides it seems that it from xcode 3 to xcode 4 the process has changed a bit.

the only thing i was told is that i need to make the banner go off the screen when theirs no connection
 
Last edited:

dejo

Moderator
Staff member
Sep 2, 2004
15,981
447
The Centennial State
see im not entirely sure that im even doing it right because form various guides it seems that it from xcode 3 to xcode 4 the process has changed a bit.

the only thing i was told is that i need to make the banner go off the screen when theirs no connection
Hmm. Then I think you need to step back a bit and become better acquainted with UIViews and their frames and how that affects their size and position on-screen.
 

johnnyfla123

macrumors newbie
Original poster
Jun 15, 2013
21
0
Hmm. Then I think you need to step back a bit and become better acquainted with UIViews and their frames and how that affects their size and position on-screen.
well i know where i want the banners. at 380 because that's where i manually dragged and checked the iad window before starting. its just weird that the iad floats to the top on the second controller. I'll keep playing with it and see
 

johnnyfla123

macrumors newbie
Original poster
Jun 15, 2013
21
0
im going to take a step back and try it again from scrath try to find a xcode 4+ tutorial
 

johnnyfla123

macrumors newbie
Original poster
Jun 15, 2013
21
0
alright i figured it out :)

Code:
-(void)bannerViewDidLoadAd:(ADBannerView *)banner {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1];
    [banner setAlpha:1];
    [UIView commitAnimations];
}

-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1];
    [banner setAlpha:0];
    [UIView commitAnimations];
}

i was looking at code that was from when iad first came out. I figured it out. thank you for pushing me in the right direction :)