SDK integration instructions
1) register with the website and add an advertisement. There will be an AdMob SDK download interface. After the download, there are examples and some files. Add the following files after your project. Admobdelegateprotocol. H, admobview. H, and libadmob.
If Objective C ++ is used, the libadmobnothumb. A must be referenced.
(2) audiotoolbox, CoreGraphics, mediaplayer, and messageui, and quartzcore Add the above framework to the project.
(3) touchjson is also added to the downloaded SDK.
(4) Register and log on, and you will get an AdMob ID.
(5) For details, see the downloaded example.ProgramSample Code.
There are three ways to add an advertisement to a program.
A) use 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) add through a program
- 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:
];
// 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) add an advertisement to 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>];