AdWhirl 3.0 + AdMob (iPhone+iPad App) 設置方法

AdWhirl 3.0 + AdMob (iPhone+iPad App) 設置方法,第1张

概述AdWhirl 3.0 + AdMob (iPhone+iPad App) 設置方法 AUG08 2011 LEAVE A COMMENT WRITTEN BY BUB-IT 如果你正在尋找如何設置 AdWhirl SDK到XCode Project 可參看 AdWhirl 3.0 + AdMob (iPhone+iPad App) 設置方法。 要 AdWhirl與 AdMob的支援你的Unive ADWhirl 3.0 + AdMob (iPhone+iPad App) 設置方法 AUG08
2011
LEAVE A COMMENT

WRITTEN BY 

BUB-IT

如果你正在尋找如何設置 ADWhirl SDK到XCode Project 可參看 AdWhirl 3.0 + AdMob (iPhone+iPad App) 設置方法。

要 ADWhirl與 AdMob的支援你的Universal App,使其同時在iPhone和iPad正常顯示,首先需要在AdMob 及ADWhirl把App 加入成兩個單獨的App,一個用於 iPhone和一個 iPad的。故先轉到 AdMob的,添加App兩次,獲得將舉兩個Publisher ID。把這兩個Publisher ID在ADWhirl中在相應的App Profile 中設置。最後您將有兩個 ADWhirl App,一個是iPhone 的,另一個iPad的,並在每個其中,有相應的AdMob Publisher ID。

在 ADWhirlVIEwDelegate class 的 aDWhirlApplicationKey method,傳回iPhone/iPad相應的ADWhirl SDK Key,如下(請把Your_ADWhirl_SDK_Key_for_iPhone和Your_ADWhirl_SDK_Key_for_iPad改成您兩個ADWhirl SDK Key):

//ADWhirlVIEwDelegate- (Nsstring *)aDWhirlApplicationKey {    if (UI_USER_INTERFACE_IdioM() == UIUserInterfaceIdiomPhone)    {        return @"Your_ADWhirl_SDK_Key_for_iPhone";    }    else    {        return @"Your_ADWhirl_SDK_Key_for_iPad";    }}

在 ADWhirl SDK 3.0中的AdMob adapter “ADWhirlAdapterGoogleAdMobAds.m”,更改getAd() method:

在method 的開端加入:

  //Request the right size ad for your device  CGSize adSize = GAD_SIZE_320x50;  if (UI_USER_INTERFACE_IdioM() == UIUserInterfaceIdiomPad)        adSize = GAD_SIZE_728x90;  CGRect adFrame = CGRectMake(0,adSize.wIDth,adSize.height);

在method 中找這一行

 GADBannerVIEw *vIEw =     [[GADBannerVIEw alloc] initWithFrame:kADWhirlVIEwDefaultFrame];

改成:

  GADBannerVIEw *vIEw =    [[GADBannerVIEw alloc] initWithFrame:adFrame];

以下是更改完成後的getAd() method:

- (voID)getAd {  //Request the right size ad for your device  CGSize adSize = GAD_SIZE_320x50;  if (UI_USER_INTERFACE_IdioM() == UIUserInterfaceIdiomPad)        adSize = GAD_SIZE_728x90;  CGRect adFrame = CGRectMake(0,adSize.height);  GADRequest *request = [GADRequest request];  NSObject *value;  NSMutableDictionary *additional = [NSMutableDictionary dictionary];  if ([aDWhirlDelegate respondsToSelector:@selector(aDWhirlTestMode)]      && [aDWhirlDelegate aDWhirlTestMode]) {    [additional setobject:@"on" forKey:@"adtest"];  }  if ((value = [self delegateValueForSelector:                      @selector(aDWhirlAdBackgroundcolor)])) {    [additional setobject:[self hexStringFromUIcolor:(UIcolor *)value]                  forKey:@"color_bg"];  }  if ((value = [self delegateValueForSelector:                      @selector(aDWhirlAdBackgroundcolor)])) {    [additional setobject:[self hexStringFromUIcolor:(UIcolor *)value]                   forKey:@"color_text"];  }  // deliberately don't allow other color specifications.  if ([additional count] > 0) {    request.additionalParameters = additional;  }  CLLocation *location =      (CLLocation *)[self delegateValueForSelector:@selector(locationInfo)];  if ((aDWhirlConfig.locationOn) && (location)) {    [request setLocationWithLatitude:location.coordinate.latitude                           longitude:location.coordinate.longitude                            accuracy:location.horizontalAccuracy];  }  Nsstring *string =      (Nsstring *)[self delegateValueForSelector:@selector(gender)];  if ([string isEqualToString:@"m"]) {    request.gender = kGADGenderMale;  } else if ([string isEqualToString:@"f"]) {    request.gender = kGADGenderFemale;  } else {    request.gender = kGADGenderUnkNown;  }  if ((value = [self delegateValueForSelector:@selector(dateOfBirth)])) {    request.birthday = (NSDate *)value;  }  if ((value = [self delegateValueForSelector:@selector(keywords)])) {    request.keywords = [NSMutableArray arrayWithArray:(NSArray *)value];  }  GADBannerVIEw *vIEw =    [[GADBannerVIEw alloc] initWithFrame:adFrame];  vIEw.adUnitID = [self publisherID];  vIEw.delegate = self;  vIEw.rootVIEwController =      [aDWhirlDelegate vIEwControllerForPresentingModalVIEw];  self.adNetworkVIEw = [vIEw autorelease];  [vIEw loadRequest:request];}

有了上面的設置和修改,iPhone 和iPad都能顯示正確的廣告尺寸,甚至iAD。

总结

以上是内存溢出为你收集整理的AdWhirl 3.0 + AdMob (iPhone+iPad App) 設置方法全部内容,希望文章能够帮你解决AdWhirl 3.0 + AdMob (iPhone+iPad App) 設置方法所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1090895.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存