Hi
I am also having same problem keyboard is not disappear after pressing "Done"
i am using Cocos2d+UIKit . if any help or sample code is appreciate please find my code here
import "TFAppDelegate.h"
UITextField *returnTextField;
@implementation MYSCENE
-(id) init
{
[super init];
[self createTextField];
return self;
}
(UITextField *)createTextField
{
CGRect frame = CGRectMake(100.0, 100.0, 100.0, 20.0);
returnTextField = [[UITextField alloc] initWithFrame:frame];
returnTextField.borderStyle = UITextBorderStyleBezel;
returnTextField.textColor = [UIColor blackColor];
returnTextField.font = [UIFont systemFontOfSize:10.0];
returnTextField.placeholder = @"";
returnTextField.backgroundColor = [UIColor whiteColor];
returnTextField.autocorrectionType = UITextAutocorrectionTypeNo; // no auto correction support
returnTextField.keyboardType = UIKeyboardTypeDefault; // use the default type input method (entire keyboard)
returnTextField.returnKeyType = UIReturnKeyDone;
//returnTextField.enablesReturnKeyAutomatically = YES;
returnTextField.clearButtonMode = UITextFieldViewModeWhileEditing; // has a clear 'x' button to the right
return returnTextField;
}
(BOOL)textFieldShouldReturn:(UITextField *)theTextField
{
[theTextField resignFirstResponder];
return YES;
}
-(void) dealloc
{
[returnTextField release];
[super dealloc];
}
@end
@implementation TFAppDelegate
(void)applicationDidFinishLaunching:(UIApplication *)application
{
// NEW: Init the window
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[window setUserInteractionEnabled:YES];
//[window setMultipleTouchEnabled:YES];
//[[Director sharedDirector] setLandscape: YES];
[[Director sharedDirector] setDisplayFPS:YES];
[[Director sharedDirector] attachInWindow:window];
Scene *scene = [Scene node];
[scene add: [MYSCENE node]];
[[[Director sharedDirector]openGLView]addSubview:returnTextField];
[window makeKeyAndVisible];
[[Director sharedDirector] runWithScene: scene];
}
-(void)dealloc
{
[super dealloc];
}
-(void) applicationWillResignActive:(UIApplication *)application
{
[[Director sharedDirector] pause];
}
-(void) applicationDidBecomeActive:(UIApplication *)application
{
[[Director sharedDirector] resume];
}
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
{
[[TextureMgr sharedTextureMgr] removeAllTextures];
}
@end