[IPhone-AdMob] how to add AdMob ads for iPhone

Source: Internet
Author: User
Tags mediawiki admob
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>];

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.