2012-07-30 2 views
0

방금 ​​iAds 및 adMob을 사용하여 내 앱에 adWhirl을 구현했습니다. 모든 것이 올바르게 컴파일되고 adMob은 완벽하게 작동하지만 내 iAd의 크기가 올바르게 설정되지 않았습니다. 광고는 적절한 크기처럼 보이지만 실제로는 잘린 것처럼 보입니다. 광고의 약 1/4이 빠진 것처럼 보입니다. 나는 버그가 없기 때문에이 문제를 해결하기 위해 어디서 정확하게 찾아야할지 모르겠습니다.광고로드가 완전히로드되지 않음

여기 내 광고 표시 줄 모양의 스크린 샷입니다.

http://imgur.com/waPPD

올바른 방향으로 어떤 도움 아니면 그냥 찔러 주시면 감사하겠습니다!

여기 AdWhirlAdapteriAd.h입니다

여기
#import "AdWhirlAdNetworkAdapter.h" 
#import <iAd/ADBannerView.h> 

@interface AdWhirlAdapterIAd : AdWhirlAdNetworkAdapter <ADBannerViewDelegate> { 
    NSString *kADBannerContentSizeIdentifierPortrait; 
    NSString *kADBannerContentSizeIdentifierLandscape; 
} 

+ (AdWhirlAdNetworkType)networkType; 

@end 

는 광고가 응용 프로그램

MainMenuInterface.h

에서 호출되는 AdWhirlAdapteriAd.m

다음
#import "AdWhirlAdapterIAd.h" 
#import "AdWhirlAdNetworkConfig.h" 
#import "AdWhirlView.h" 
#import "AdWhirlLog.h" 
#import "AdWhirlAdNetworkAdapter+Helpers.h" 
#import "AdWhirlAdNetworkRegistry.h" 

@implementation AdWhirlAdapterIAd 

+ (AdWhirlAdNetworkType)networkType { 
    return AdWhirlAdNetworkTypeIAd; 
} 

+ (void)load { 
    if(NSClassFromString(@"ADBannerView") != nil) { 
    [[AdWhirlAdNetworkRegistry sharedRegistry] registerClass:self]; 
    } 
} 

- (void)getAd { 
    ADBannerView *iAdView = [[ADBannerView alloc] initWithFrame:CGRectZero]; 
    kADBannerContentSizeIdentifierPortrait = 
    &ADBannerContentSizeIdentifierPortrait != nil ? 
     ADBannerContentSizeIdentifierPortrait : 
     ADBannerContentSizeIdentifierPortrait; 
    kADBannerContentSizeIdentifierLandscape = 
    &ADBannerContentSizeIdentifierLandscape != nil ? 
     ADBannerContentSizeIdentifierLandscape : 
     ADBannerContentSizeIdentifierPortrait; 
    iAdView.requiredContentSizeIdentifiers = [NSSet setWithObjects: 
             kADBannerContentSizeIdentifierPortrait, 
             kADBannerContentSizeIdentifierLandscape, 
             nil]; 
    UIDeviceOrientation orientation; 
    if ([self.adWhirlDelegate respondsToSelector:@selector(adWhirlCurrentOrientation)]) { 
orientation = [self.adWhirlDelegate adWhirlCurrentOrientation]; 
    } 
    else { 
    orientation = [UIDevice currentDevice].orientation; 
    } 

    if (UIDeviceOrientationIsLandscape(orientation)) { 
    iAdView.currentContentSizeIdentifier = kADBannerContentSizeIdentifierLandscape; 
    } 
    else { 
    iAdView.currentContentSizeIdentifier = kADBannerContentSizeIdentifierPortrait; 
    } 
    [iAdView setDelegate:self]; 

    self.adNetworkView = iAdView; 
    [iAdView release]; 
} 

- (void)stopBeingDelegate { 
    ADBannerView *iAdView = (ADBannerView *)self.adNetworkView; 
    if (iAdView != nil) { 
    iAdView.delegate = nil; 
    } 
} 

- (void)rotateToOrientation:(UIInterfaceOrientation)orientation { 
    ADBannerView *iAdView = (ADBannerView *)self.adNetworkView; 
    if (iAdView == nil) return; 
    if (UIInterfaceOrientationIsLandscape(orientation)) { 
    iAdView.currentContentSizeIdentifier = kADBannerContentSizeIdentifierLandscape; 
    } 
    else { 
    iAdView.currentContentSizeIdentifier = kADBannerContentSizeIdentifierPortrait; 
    } 
    // ADBanner positions itself in the center of the super view, which we do not 
    // want, since we rely on publishers to resize the container view. 
    // position back to 0,0 
    CGRect newFrame = iAdView.frame; 
    newFrame.origin.x = newFrame.origin.y = 0; 
    iAdView.frame = newFrame; 
} 

- (BOOL)isBannerAnimationOK:(AWBannerAnimationType)animType { 
    if (animType == AWBannerAnimationTypeFadeIn) { 
    return NO; 
    } 
    return YES; 
} 

- (void)dealloc { 
    [super dealloc]; 
} 

#pragma mark IAdDelegate methods 

- (void)bannerViewDidLoadAd:(ADBannerView *)banner { 
    // ADBanner positions itself in the center of the super view, which we do not 
    // want, since we rely on publishers to resize the container view. 
    // position back to 0,0 
    CGRect newFrame = banner.frame; 
    newFrame.origin.x = newFrame.origin.y = 0; 
    banner.frame = newFrame; 

    [adWhirlView adapter:self didReceiveAdView:banner]; 
} 

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error { 
    [adWhirlView adapter:self didFailAd:error]; 
} 

- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:    (BOOL)willLeave { 
    [self helperNotifyDelegateOfFullScreenModal]; 
    return YES; 
} 

- (void)bannerViewActionDidFinish:(ADBannerView *)banner { 
    [self helperNotifyDelegateOfFullScreenModalDismissal]; 
} 

@end 

입니다

#import <Foundation/Foundation.h> 
#import "cocos2d.h" 
#import "GameManager.h" 
#import "AdWhirlView.h" 
#import "AdWhirlDelegateProtocol.h" 
#import "Reading_FluencyAppDelegate.h" 
#import "RootViewController.h" 

enum GameStatePP { 
    kGameStatePlaying, 
    kGameStatePaused 
}; 


@interface MainMenuInterface : CCLayer <AdWhirlDelegate> 

{ 
    CCMenu *mainMenu; 
    CCMenu *aboutPage; 

    RootViewController *viewController; 
    AdWhirlView *adWhirlView; 
    enum GameStatePP _state; 
} 

@property(nonatomic,retain) AdWhirlView *adWhirlView; 
@property(nonatomic) enum GameStatePP state; 

-(void)displayStartButton; 

@end 

여기가

- (void)adWhirlWillPresentFullScreenModal { 

    if (self.state == kGameStatePlaying) { 

     //[[SimpleAudioEngine sharedEngine] pauseBackgroundMusic]; 

     [[CCDirector sharedDirector] pause]; 
    } 
} 

- (void)adWhirlDidDismissFullScreenModal { 

    if (self.state == kGameStatePaused) 
     return; 

    else { 
     self.state = kGameStatePlaying; 
     //[[SimpleAudioEngine sharedEngine] resumeBackgroundMusic]; 
     [[CCDirector sharedDirector] resume]; 

    } 
} 

- (NSString *)adWhirlApplicationKey { 
    return @"23myapplicationkey39203924"; 
} 

- (UIViewController *)viewControllerForPresentingModalView { 
    return viewController; 
} 

-(void)adjustAdSize { 
    [UIView beginAnimations:@"AdResize" context:nil]; 
    [UIView setAnimationDuration:0.2]; 
    CGSize adSize = [adWhirlView actualAdSize]; 
    CGRect newFrame = adWhirlView.frame; 
newFrame.size.height = adSize.height; 

CGSize winSize = [CCDirector sharedDirector].winSize; 
newFrame.size.width = winSize.width; 
newFrame.origin.x = (self.adWhirlView.bounds.size.width - adSize.width)/2; 

newFrame.origin.y = (winSize.height - adSize.height); 
adWhirlView.frame = newFrame; 
[UIView commitAnimations]; 
} 

- (void)adWhirlDidReceiveAd:(AdWhirlView *)adWhirlVieww { 
[adWhirlView rotateToOrientation:UIInterfaceOrientationLandscapeRight]; 
[self adjustAdSize]; 

} 

-(void)onEnter { 
    viewController = [(Reading_FluencyAppDelegate *)[[UIApplication sharedApplication]   delegate] viewController]; 
    self.adWhirlView = [AdWhirlView requestAdWhirlViewWithDelegate:self]; 
    self.adWhirlView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin; 

    [adWhirlView updateAdWhirlConfig]; 
CGSize adSize = [adWhirlView actualAdSize]; 
CGSize winSize = [CCDirector sharedDirector].winSize; 
self.adWhirlView.frame = CGRectMake((winSize.width/2)-(adSize.width/2),winSize.height-   adSize.height,winSize.width,adSize.height); 
self.adWhirlView.clipsToBounds = YES; 
[viewController.view addSubview:adWhirlView]; 
[viewController.view bringSubviewToFront:adWhirlView]; 
[super onEnter]; 
} 

-(void)onExit { 
if (adWhirlView) { 
    [adWhirlView removeFromSuperview]; 
    [adWhirlView replaceBannerViewWith:nil]; 
    [adWhirlView ignoreNewAdRequests]; 
    [adWhirlView setDelegate:nil]; 
    self.adWhirlView = nil; 
} 
[super onExit]; 
} 

-(void)dealloc 
{ 
self.adWhirlView.delegate = nil; 
self.adWhirlView = nil; 
[super dealloc]; 
} 
+0

무엇이 잘못되었는지 확인하려면 iAd 코드를 보여줘야합니다. 스냅 샷으로는 충분하지 않습니다. – Sumanth

+0

은 관련성이 있다고 생각되는 코드로 업데이트되었습니다. 앱 대리인 코드가 필요한지 알려주세요. –

답변

0

, 내 문제는 대신 세로의 풍경 광고를 호출하는 것을 밝혀졌다, 그것은) (adjustAdSize보다라고 할 때 올바른 크기 조정을 얻지 못했습니다.

은 내가

- (void)adWhirlDidReceiveAd:(AdWhirlView *)adWhirlVieww { 
    [adWhirlView rotateToOrientation:UIInterfaceOrientationPortrait]; 
    [self adjustAdSize]; 
{ 

- (void)adWhirlDidReceiveAd:(AdWhirlView *)adWhirlVieww { 
    [adWhirlView rotateToOrientation:UIInterfaceOrientationLandscapeRight]; 
    [self adjustAdSize]; 
{ 

을 변경하고 그것은 나의 모든 문제를 해결!

1

어쩌면 당신의 sharedDirector에 대한 winSize 속성은 여전히에서 초상화를 생각 MainMenuInterface.m에서 중요한 물건인가? 당신이했다, 그래서 당신이 그것을 이성을 상실하면 어떻게 : 미래에 알아야 할 것들에 대한

newFrame.size.width = winSize.height; 
newFrame.origin.x = (self.adWhirlView.bounds.size.width - adSize.width)/2; 

newFrame.origin.y = (winSize.width - adSize.height); 
adWhirlView.frame = newFrame; 
+0

의견을 보내 주셔서 감사합니다. 이러한 변경을 시도하면 초상화 광고 크기가 아닌 가로 광고 크기가 필요하다는 것을 알게되었습니다. –

관련 문제