我正在尝试以编程方式将焦点设置在我使用 becomeFirstResponder 创建的新 UITextField 上。还有其他方法吗?
-(void) editPlayerName
{
lblPLayerName.visible = FALSE;
NSString* fontNm = @"Chalkduster";
tfPlayerName = [[UITextField alloc] initWithFrame:CGRectMake(40,20,200,24)];
tfPlayerName.text = [myS playerName];
tfPlayerName.borderStyle = UITextBorderStyleNone;
tfPlayerName.textColor = [UIColor redColor];
tfPlayerName.font = [UIFont fontWithName:fontNm size:20];
tfPlayerName.delegate = self;
UIView* glView = [CCDirector sharedDirector].openGLView;
[glView addSubview:tfPlayerName];
[tfPlayerName becomeFirstResponder];
}