2012-04-22 2 views
2

나는 거의 모든 곳에서 답을 찾았다.iPhone 화면 상단에 Admob을 표시하는 방법은 무엇입니까?

// 
// GADAdSize.h 
// Google Ads iOS SDK 
// 
// Copyright 2012 Google Inc. All rights reserved. 
// 
// A valid GADAdSize is considered to be one of the predefined GADAdSize 
// constants or a GADAdSize constructed by GADAdSizeFromCGSize, 
// GADAdSizeFullWidthPortraitWithHeight, GADAdSizeFullWidthLandscapeWithHeight. 
// 

#import <UIKit/UIKit.h> 

// Do not create a GADAdSize manually. Use one of the kGADAdSize constants. 
// Treat GADAdSize as an opaque type. Do not access any fields directly. To 
// obtain a concrete CGSize, use the function CGSizeFromGADAdSize(). 
typedef struct GADAdSize { 
    CGSize size; 
    NSUInteger flags; 
} GADAdSize; 

#pragma mark Standard Sizes 

// iPhone and iPod Touch ad size. Typically 320x50. 
extern GADAdSize const kGADAdSizeBanner; 

// Medium Rectangle size for the iPad (especially in a UISplitView's left pane). 
// Typically 300x250. 
extern GADAdSize const kGADAdSizeMediumRectangle; 

// Full Banner size for the iPad (especially in a UIPopoverController or in 
// UIModalPresentationFormSheet). Typically 468x60. 
extern GADAdSize const kGADAdSizeFullBanner; 

// Leaderboard size for the iPad. Typically 728x90. 
extern GADAdSize const kGADAdSizeLeaderboard; 

// Skyscraper size for the iPad. Mediation only. AdMob/Google does not offer 
// this size. Typically 120x600. 
extern GADAdSize const kGADAdSizeSkyscraper; 

// An ad size that spans the full width of the application in portrait 
// orientation. The height is typically 50 pixels on an iPhone/iPod UI, and 90 
// pixels tall on an iPad UI. 
extern GADAdSize const kGADAdSizeSmartBannerPortrait; 

// An ad size that spans the full width of the application in landscape 
// orientation. The height is typically 32 pixels on an iPhone/iPod UI, and 90 
// pixels tall on an iPad UI. 
extern GADAdSize const kGADAdSizeSmartBannerLandscape; 

// Invalid ad size marker. 
extern GADAdSize const kGADAdSizeInvalid; 

#pragma mark Custom Sizes 

// Given a CGSize, return a custom GADAdSize. Use this only if you require a 
// non-standard size, otherwise, use one of the standard size constants above. 
GADAdSize GADAdSizeFromCGSize(CGSize size); 

// Get a custom GADAdSize that spans the full width of the application in 
// portrait orientation with the height provided. 
GADAdSize GADAdSizeFullWidthPortraitWithHeight(CGFloat height); 

// Get a custom GADAdSize that spans the full width of the application in 
// landscape orientation with the height provided. 
GADAdSize GADAdSizeFullWidthLandscapeWithHeight(CGFloat height); 

#pragma mark Convenience Functions 

// Checks whether the two GADAdSizes are equal. 
BOOL GADAdSizeEqualToSize(GADAdSize size1, GADAdSize size2); 

// Given a GADAdSize constant, returns a CGSize. If the GADAdSize is unknown, 
// returns CGSizeZero. 
CGSize CGSizeFromGADAdSize(GADAdSize size); 

// Determines if |size| is one of the predefined constants, or a custom 
// GADAdSize generated by FromCGSize. 
BOOL IsGADAdSizeValid(GADAdSize size); 

// Given a GADAdSize constant, returns a NSString describing the GADAdSize. 
NSString *NSStringFromGADAdSize(GADAdSize size); 


#pragma mark Deprecated Macros 

#define GAD_SIZE_320x50  CGSizeFromGADAdSize(kGADAdSizeBanner) 
#define GAD_SIZE_300x250 CGSizeFromGADAdSize(kGADAdSizeMediumRectangle) 
#define GAD_SIZE_468x60  CGSizeFromGADAdSize(kGADAdSizeFullBanner) 
#define GAD_SIZE_728x90  CGSizeFromGADAdSize(kGADAdSizeLeaderboard) 
#define GAD_SIZE_120x600 CGSizeFromGADAdSize(kGADAdSizeSkyscraper) 

이가있는 viewDidLoad 예제 프로젝트에 주어진 것입니다.

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    // Initialize the banner at the bottom of the screen. 
    CGPoint origin = CGPointMake(0.0, 
           self.view.frame.size.height - 
           CGSizeFromGADAdSize(kGADAdSizeBanner).height); 





    // Use predefined GADAdSize constants to define the GADBannerView. 
    self.adBanner = [[[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner 
                origin:origin] 
        autorelease]; 

    // Note: Edit SampleConstants.h to provide a definition for kSampleAdUnitID 
    // before compiling. 
    self.adBanner.adUnitID = kSampleAdUnitID; 
    self.adBanner.delegate = self; 
    [self.adBanner setRootViewController:self]; 
    [self.view addSubview:self.adBanner]; 
    [self.adBanner loadRequest:[self createRequest]]; 
} 

나는 목표 C에서 최고 아니에요,이 코드를 호출 할 때 무슨 일이 일어나고 있는지에 대한 간단한 설명을 사용할 수 있습니다. Android와 관련하여 이와 비슷한 질문이 있습니다. iPhoners를 요청할 것이라고 생각했습니다. Google의 모든 사용자가 비추천 매크로를 사용하고 있습니다.

답변

3

당신이보고있는 예제 코드가 화면의 하단에 원점으로 화면의 하단에 광고를 초기화는 (기원은 특히 (0, HEIGHT_OF_SCREEN-HEIGHT_OF_AD)입니다

initWithSize :. 광고를 초기화하는 생성자 기본값 (0,0)에서 화면 상단에 당신은 너무로 adBanner를 초기화 그렇다면 :

self.adBanner = [[[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner] 
        autorelease]; 

당신은 광고가 화면 상단에 와서 볼 수

을.
관련 문제