[fixed] Pop a keyboard when integrated admob

[fixed] Pop a keyboard when integrated admob
0.0 0


Pop a keyboard when integrated admob

He and I have met with the same problems.

Ref post on google group:
We are using admob in our apps ( our apps are cocos2d-x based - a C++
cross platform).
After clicking an Admob ad the keyboard is opened (not immediately -
it happens when the ad is replaced , after the next loadRequest is
called) .


This problem has a chance to appear, when you click or long press the admob ad view
This is a bug?

key code in AppController.mm


    viewController.view = __glView;

    bannerView_ = [[GADBannerView alloc]
    bannerView_.adUnitID = @"a14f29067d6a59a";

    // Let the runtime know which UIViewController to restore after taking
    // the user wherever the ad goes and add it to the view hierarchy.

    bannerView_.rootViewController = viewController;
    //    [self.view addSubview:bannerView_];

    // Initiate a generic request to load it with an ad.
    GADRequest *request = [GADRequest request];
    //    [request setTesting:YES];
    request.additionalParameters =
    [NSMutableDictionary dictionaryWithObjectsAndKeys:
     @"AAAAFF", @"color_bg",
     @"FFFFFF", @"color_bg_top",
     @"FFFFFF", @"color_border",
     @"000080", @"color_link",
     @"808080", @"color_text",
     @"008000", @"color_url",

//    [bannerView_ setDelegate:viewController];
    [bannerView_ loadRequest:request];
    [__glView addSubview: bannerView_];

    // Set RootViewController to window
    [window addSubview: viewController.view];

iOS Simulator Screen shot Feb 10, 2012 10.47.38 PM.png (89.6 KB)


Hello all,

we have same issue and similar code. We found out that EAGLView show up keyboard for some reason. Looks like GADBannerView triggers it, but not sure why. Didn’t have time to check it more deeply, we just disabled keyboard in the moment, as we don’t use it at all, but this is not solution. If anyone was looked to this problem more deeply, we will gladly appreciate.


Vladislav Spevak


Just run into this problem myself with implementing iAd. Have a look at this: http://www.cocos2d-x.org/boards/6/topics/9968

I’ve just added the patch code to my “cocos2d-1.0.1-x-0.11.0” based game and it fixes the issue. The code is slightly different to the patch shown, everything is the same except in “EAGLView.mm” the first patch line “acceptFirstResponder_ = NO;” should go in:

- (id) initWithFrame:(CGRect)frame pixelFormat:(NSString*)format depthFormat:(GLuint)depth preserveBackbuffer:(BOOL)retained sharegroup:(EAGLSharegroup*)sharegroup multiSampling:(BOOL)sampling numberOfSamples:(unsigned int)nSamples;
    if((self = [super initWithFrame:frame]))
        pixelformat_ = format;
        depthFormat_ = depth;
        multiSampling_ = sampling;
        requestedSamples_ = nSamples;
        preserveBackbuffer_ = retained;
        markedText_ = nil;
        if( ! [self setupSurfaceWithSharegroup:sharegroup] ) {
            [self release];
            return nil;
        touchesIntergerDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 4, NULL, NULL);
        indexBitsUsed = 0x00000000;

        acceptFirstResponder_ = NO;     // patch
        view = self;

    return self;



I have same problem. Thank you for sharing.

Is there any chance that the decision comes in the official repository?