[fixed] keypad popping up for no reason

[fixed] keypad popping up for no reason
0.0 0


I realize that (only on iOS5) my mpmovieviewcontroller causes the keypad to automatically pops up for no reason. It didn’t happen in iOS4 and earlier versions.

I googled a bit and people are saying it has something to do with Apple’s changes in iOS5. I tried to call resignfirstresponder when the screen is tapped but that doesn’t help.


Hi guys. I have managed to hide the keyboard using resignFirstResponder on the sharedEAGLView instead of the movie player’s view.
But now the problem is, when I call resignFirstResponder, I can still see the keyboard popping out but right after that it pops down again.

Is there anyway I can prevent the keyboard from appearing at all?


Could you provide some code or a code snippet, that can reproduc the issue?
I have seen this behaviour with several admob ads, but wasn’t able to reproduce and track down the issue.



#import "cocos2d.h"

@interface moviePlayer : MPMoviePlayerController
    MPMoviePlayerViewController *mpviewController;

- (id)init;
- (void)dealloc;
- (IBAction)play;
- (void)playbackFinishedCallback:(NSNotification *)notification;



#import "moviePlayer.h"

@implementation moviePlayer

- (id)init
    self = [super init];
    if (self)
        // Initialization code here
        running = true;

    return self;

- (void)dealloc
    [mpviewController release];
    [super dealloc];

- (IBAction)play {

    NSString *movpath = [[NSBundle mainBundle] pathForResource:@"intro" ofType:@"mp4"];
    mpviewController = [[MPMoviePlayerViewController alloc]
                        initWithContentURL:[NSURL fileURLWithPath:movpath]];
    [mpviewController.moviePlayer setControlStyle:MPMovieControlStyleNone];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackFinishedCallback:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification object:nil];

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
        mpviewController.view.frame = CGRectMake(0, 0, 480, 320);
        mpviewController.view.frame = CGRectMake(0, 0, 1024, 768);

    [self.view addSubview:mpviewController.view];

- (void)playbackFinishedCallback:(NSNotification *)notification
    mpviewController = [notification object];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:mpviewController];
    [mpviewController.view removeFromSuperview];


How to use it:

moviePlayer *movie; = [[moviePlayer alloc] init];
[movie play];

UIView* view = [EAGLView sharedEGLView];
[view addSubview:movie.view];


I haven’t tested it with your code but found a repro in my own.
In my case terminating the view sometimes called becomeFirstResponder on the EGLView.

Therefore I’ve added an additional property called acceptFirstResponder to the EAGLView.
if the property is set to NO (which is the default) the EGLVIew cannot become the first responder.

If the keyboard is requested by CCEAGLView::setIMEKeyboardState() the property is set to YES before the call and NO afterwards.
The solution feels a little hacky, but I’m not an iOS expert either.

Attached is the patch you might try.


Thanks! It works! :slight_smile: