2011-12-24 68 views
0

下面是要显示的代码。键盘未在cocos2d中显示uitextfield

UIViewController* viewControoler = [[UIViewController alloc]init]; 
textfield = [[UITextField alloc]initWithFrame:CGRectMake(0,0,280,90)]; 
textfield.placeholder = @"word"; 
textfield.keyboardType = UIKeyboardTypeDefault; 
textfield.returnKeyType = UIReturnKeySearch; 
textfield.clearButtonMode = UITextFieldViewModeWhileEditing; 
textfield.delegate = self; 
textfield.userInteractionEnabled = YES; 
[textfield becomeFirstResponder]; 
[viewControoler.view addSubview:textfield]; 
[[[CCDirector sharedDirector]openGLView] addSubview:viewControoler.view]; 

它运行良好。但是,textfield不可编辑,因为当我点击uitextfiled时,键盘不会到来。

回答

1

删除的UIViewController,直接添加在OpenGLView,

textfield = [[UITextField alloc]initWithFrame:CGRectMake(0,0,280,90)]; 
textfield.placeholder = @"word"; 
textfield.keyboardType = UIKeyboardTypeDefault; 
textfield.returnKeyType = UIReturnKeySearch; 
textfield.clearButtonMode = UITextFieldViewModeWhileEditing; 
textfield.delegate = self; 
textfield.userInteractionEnabled = YES; 
[textfield becomeFirstResponder]; 

[[[CCDirector sharedDirector]openGLView] addSubview:textfield; 
相关问题