views:

114

answers:

2

Hi, 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.

+1  A: 

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.

davbryn
Sorry, I should have made it clear that it is not an Objective C app, it is simply an JSP web page. Any solutions in java, html, css, or javascript? thanks.
Linda
+1  A: 

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.

Matt Moriarity