在新的UITextField上使用becomeFirstResponder

时间:2013-04-26 04:09:06

标签: objective-c uiview cocos2d-iphone uitextfield becomefirstresponder

我正在尝试以编程方式将焦点设置在我使用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];

}

0 个答案:

没有答案