[iphone-adMob]如何为iphone添加admob广告

SDK Integration instructions

1) 到网站注册,添加广告。之后会有一个admob sdk 下载界面,下载之后,里面有例子和一些文件。到你的工程之后添加如下的文件。AdMobDelegateProtocol.h, AdMobView.h, and libAdMob.a

如果使用objective c++那么需要引用的是这个 libAdMobNoThumb.a

(2) AudioToolbox, CoreGraphics, MediaPlayer, and MessageUI, QuartzCore 把以上的framework 添加到工程中。 

(3) TouchJSON 也在下载好的sdk里面,也要添加。

(4) 注册好了登陆,你会获得一个admob 的ID

(5) 具体的可以看下载好的例子里面,有相关的程序,sample code等。

一共有三种添加到程序中的广告的方法。

A) 使用Interface builder

  • Add AdViewController.h and AdViewController.m to your project (located in the IBSupport subdirectory).
  • Open Interface Builder.
  • Place a 320x48 UIView where you want the ad to appear.
  • Add an Object, and change its type to AdViewController.
  • Set the view outlet of the AdViewController to your UIView.
  • Set the currentViewController outlet of the AdViewController to the UIViewController owning the xib.
  • Edit AdViewController.m to make sure that your publisher ID and other options are set correctly.

B) 通过程序进行添加

  • Create an AdMob delegate class; it can be as simple as a class that only implements -publisherId and -currentViewController .
  • Add the following code to your view creation (modify as appropriate):
  AdMobView *ad = [AdMobView requestAdWithDelegate:<your delegate>]; 
// start a new ad request
  ad.frame = CGRectMake(0, 432, 320, 48); // set the frame, 
in this case at the bottom of the screen
  [self.window addSubview:ad]; // attach the ad to the view hierarchy;
 self.window is responsible for retaining the ad

C) 在 tableView里面添加一个广告

  • Create an AdMob delegate class; it can be as simple as a class that only implements -publisherId and -currentViewController.
  • Add to your -tableView:cellForRowAtIndexPath: method (modify as appropriate):
  [cell.contentView addSubview:[AdMobView requestAdWithDelegate:
<your delegate>]];
posted @ 2010-05-20 13:39  AlexLiu  阅读(2765)  评论(1编辑  收藏  举报