Guest User

Untitled

a guest
Apr 19th, 2013
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. CSAppDelegate.h
  2. #import <UIKit/UIKit.h>
  3.  
  4.  
  5. @interface CSAppDelegate : UIResponder <UIApplicationDelegate>
  6. //@property(nonatomic, retain) UIViewController *CSViewController;
  7. @property (strong, nonatomic) UIWindow *window;
  8.  
  9. @end
  10.  
  11. CSAppDelegate.m
  12.  
  13. #import "CSAppDelegate.h"
  14. #import "CSViewController.h"
  15.  
  16. @implementation CSAppDelegate
  17.  
  18. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  19. {
  20. CSViewController * vc = [[CSViewController alloc]init];
  21. [vc viewDidLoad];
  22. return YES;
  23. }
  24.  
  25. - (void)applicationWillResignActive:(UIApplication *)application
  26. {
  27. // 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.
  28. // 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.
  29. }
  30.  
  31. - (void)applicationDidEnterBackground:(UIApplication *)application
  32. {
  33. // 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.
  34. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
  35. }
  36.  
  37. - (void)applicationWillEnterForeground:(UIApplication *)application
  38. {
  39. // 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.
  40. }
  41.  
  42. - (void)applicationDidBecomeActive:(UIApplication *)application
  43. {
  44. // 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.
  45. }
  46.  
  47. - (void)applicationWillTerminate:(UIApplication *)application
  48. {
  49. // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
  50. }
  51.  
  52.  
  53. @end
  54.  
  55. CSViewController.h
  56. #import "GADBannerView.h"
  57.  
  58. @interface CSViewController : UIViewController {
  59. // Declare one as an instance variable
  60. GADBannerView *bannerView_;
  61. }
  62.  
  63. @end
  64.  
  65. CSViewController.m
  66. #import "CSViewController.h"
  67. #define MY_BANNER_UNIT_ID @"aXXXXXXXXXXXX"
  68.  
  69. @implementation CSViewController
  70.  
  71. - (void)viewDidLoad {
  72. [super viewDidLoad];
  73.  
  74. // Create a view of the standard size at the top of the screen.
  75. // Available AdSize constants are explained in GADAdSize.h.
  76. bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
  77.  
  78. // Specify the ad's "unit identifier." This is your AdMob Publisher ID.
  79. bannerView_.adUnitID = MY_BANNER_UNIT_ID;
  80.  
  81. // Let the runtime know which UIViewController to restore after taking
  82. // the user wherever the ad goes and add it to the view hierarchy.
  83. bannerView_.rootViewController = self;
  84. [self.view addSubview:bannerView_];
  85.  
  86. // Initiate a generic request to load it with an ad.
  87. [bannerView_ loadRequest:[GADRequest request]];
  88. }
  89.  
  90. - (void)dealloc {
  91.  
  92. // Don't release the bannerView_ if you are using ARC in your project
  93. }
  94.  
  95. @end
Advertisement
Add Comment
Please, Sign In to add comment