2011-12-24 98 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; 
相關問題