开发者

iphone development - automatically pop up keypad on a form

I have a form which I want the user to fill 开发者_开发问答in and I want to have the keypad to pop up on the iphone automatically when they hit that page instead of them tapping on the input box first. What is the special tag in order to achieve that?

Also, is it possible to set a timer, eg: 3 seconds, then have the keypad pop up, instead of popping up immediately.

Thanks in advance.


In your -(void)viewDidAppear:(BOOL)animated calling [theTextField becomeFirstResponder]; will make the keyboard appear for you (where theTextField is the first textField on the form.

If you set up a method as follows:

-(void) setFocusToTextbox {
[theTextField becomeFirstResponder];

}

and in -(void)viewDidAppear:(BOOL)animated have:

[NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(setFocusToTextbox) userInfo:nil repeats:NO]; 

The keyboard should appear 3.0 seconds after the view does.


There's no tag, but there is JavaScript to do it. After your page has loaded, you need to call focus() on the textfield you want the keyboard to show for.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜