Now if anyone wants to achieve this in iOS 6, he can open iOS keyboard programmatically like this,
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
// keyboardDisplayRequiresUserAction available in iOS >= 6
if ([webView respondsToSelector:@selector(setKeyboardDisplayRequiresUserAction:)]) {
webView.keyboardDisplayRequiresUserAction = NO;
}
}
and then,
- (void)webViewDidFinishLoad:(UIWebView *)webView {
// Assuming that you're using jquery. If not, use document.getElementById('YourInputElementID')
NSString *evalStr = [NSString stringWithFormat:@"setTimeout( function(){$('#YourInputElementID').focus();},1000);"];
[webView stringByEvaluatingJavaScriptFromString:evalStr];
}
This will run this javascript after 1sec. For safe side you should call the get focus code when the focusing element has been loaded.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…