Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CSAppDelegate.h
- #import <UIKit/UIKit.h>
- @interface CSAppDelegate : UIResponder <UIApplicationDelegate>
- //@property(nonatomic, retain) UIViewController *CSViewController;
- @property (strong, nonatomic) UIWindow *window;
- @end
- CSAppDelegate.m
- #import "CSAppDelegate.h"
- #import "CSViewController.h"
- @implementation CSAppDelegate
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- {
- CSViewController * vc = [[CSViewController alloc]init];
- [vc viewDidLoad];
- return YES;
- }
- - (void)applicationWillResignActive:(UIApplication *)application
- {
- // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
- // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
- }
- - (void)applicationDidEnterBackground:(UIApplication *)application
- {
- // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
- // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
- }
- - (void)applicationWillEnterForeground:(UIApplication *)application
- {
- // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
- }
- - (void)applicationDidBecomeActive:(UIApplication *)application
- {
- // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
- }
- - (void)applicationWillTerminate:(UIApplication *)application
- {
- // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
- }
- @end
- CSViewController.h
- #import "GADBannerView.h"
- @interface CSViewController : UIViewController {
- // Declare one as an instance variable
- GADBannerView *bannerView_;
- }
- @end
- CSViewController.m
- #import "CSViewController.h"
- #define MY_BANNER_UNIT_ID @"aXXXXXXXXXXXX"
- @implementation CSViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Create a view of the standard size at the top of the screen.
- // Available AdSize constants are explained in GADAdSize.h.
- bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
- // Specify the ad's "unit identifier." This is your AdMob Publisher ID.
- bannerView_.adUnitID = MY_BANNER_UNIT_ID;
- // Let the runtime know which UIViewController to restore after taking
- // the user wherever the ad goes and add it to the view hierarchy.
- bannerView_.rootViewController = self;
- [self.view addSubview:bannerView_];
- // Initiate a generic request to load it with an ad.
- [bannerView_ loadRequest:[GADRequest request]];
- }
- - (void)dealloc {
- // Don't release the bannerView_ if you are using ARC in your project
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment