Hello;
My main app uses a Tab Bar Controller in the MainWindow.xib.
I understand the mechanics of adding the AdMob stuff to a generic view, but I'm having a difficult time glueing the concepts in my head enough to add it just above the Tab Bar controller. I want the ads there so that they are present as the user moves about my app.
Or should I incorporate the ads on each of the seperate view controllers that the tab bar controller controls?
Thanks.
Hi, I have the exact same problem, can you please share the steps that fixed it?
In my opinion, putting ads at the very top or the very bottom breaks the look and feel of the iPhone interface. I just don't like the way it looks. Take a peek at weather.com app and you'll see what I mean.
Since almost all of my view controllers are tables, I decided to display the ads in a TableViewHeader. It looks good and the user can scroll it away if the display is big enough - I sort of like that behavior.
So here's what I did to implement it:
In my view controller's viewDidLoad I have the following:
Code:
if (tableHeaderView == nil) {
CGRect frameRectangle = CGRectMake(0.0f, 0.0f, 320.0f, 48.0f);
tableHeaderView = [[UIView alloc] initWithFrame:frameRectangle];
tableHeaderView.backgroundColor = [UIColor colorWithRed:0.208 green:0.435 blue:0.659 alpha:1];
self.tableView.tableHeaderView = tableHeaderView;
}
// Request an ad
adMobAd = [AdMobView requestAdWithDelegate:self];
[adMobAd retain]; // this will be released when it loads (or fails to load)
tableHeaderView is defined as a UIView in my .h file. Then, I do the following assignment in the AdMob callback didReceiveAd;
In my opinion, putting ads at the very top or the very bottom breaks the look and feel of the iPhone interface. I just don't like the way it looks. Take a peek at weather.com app and you'll see what I mean.
Since almost all of my view controllers are tables, I decided to display the ads in a TableViewHeader. It looks good and the user can scroll it away if the display is big enough - I sort of like that behavior.
So here's what I did to implement it:
In my view controller's viewDidLoad I have the following:
Code:
if (tableHeaderView == nil) {
CGRect frameRectangle = CGRectMake(0.0f, 0.0f, 320.0f, 48.0f);
tableHeaderView = [[UIView alloc] initWithFrame:frameRectangle];
tableHeaderView.backgroundColor = [UIColor colorWithRed:0.208 green:0.435 blue:0.659 alpha:1];
self.tableView.tableHeaderView = tableHeaderView;
}
// Request an ad
adMobAd = [AdMobView requestAdWithDelegate:self];
[adMobAd retain]; // this will be released when it loads (or fails to load)
tableHeaderView is defined as a UIView in my .h file. Then, I do the following assignment in the AdMob callback didReceiveAd;
So that's how I implemented AdMob ads in my app. Hope that helps!
/H
Hello, I am very new at developing for the iphone but have managed to get the AdMob code working in my normal views. But a portion of my app is in Tables. When I add the code to the tables it does work but the first record is always cut off. I tried using your method from above, but I think some steps were left out.
I am getting the following errors after using your code:
error: 'adMobAd' undeclared (first used in this function)
error: 'AdMobView' undeclared (first used in this function)
error: request for member 'tableView' in something not a structure or union.
Any help would be appreciated.. Baby steps would help too
Hello, I am very new at developing for the iphone but have managed to get the AdMob code working in my normal views. But a portion of my app is in Tables. When I add the code to the tables it does work but the first record is always cut off. I tried using your method from above, but I think some steps were left out.
I am getting the following errors after using your code:
error: 'adMobAd' undeclared (first used in this function)
error: 'AdMobView' undeclared (first used in this function)
error: request for member 'tableView' in something not a structure or union.
Any help would be appreciated.. Baby steps would help too
Thanks
It looks like you didn't declare anything in your .h file!
Something like this might help:
Code:
#define AD_REFRESH_PERIOD 60.0 // display fresh ads once per minute
#import <UIKit/UIKit.h>
#import "AdMobDelegateProtocol.h";
@class AdMobView;
@interface AdViewController : UIViewController<AdMobDelegate> {
AdMobView *adMobAd; // the actual ad; self.view is a placeholder to indicate where the ad should be placed; intentially _not_ an IBOutlet
NSTimer *refreshTimer; // timer to get fresh ads
}
- (void)refreshAd:(NSTimer *)timer;
@end
Take a look at the AdMob sample app that comes with their SDK. That will help a lot.
Ok, I tried putting the code in the header and got nowhere. I appreciate you trying to help me. I am attaching code for my files that need to be modified (I believe). I would appreciate it if you could help with this.
I know this is a lot of code to look into and even perhaps outside the scope of this forum. But I am beginner at this and I am stuck. Thanks
Ok. I see the code that you have here.
You have to have the AdMob SDK downloaded and installed in your Xcode project. Did you do that? Where are you implementing any of the AdMob stuff? [See previous code from last post]