我希望当我在输入文本框上调用 $('#elementId').focus() 时自动显示键盘。有办法实现这个吗?
最佳答案
由于浏览器安全限制,仅在元素上使用 .focus() 会受到限制。但是,您可以写 Trigger.io native plugin对于 iOS 6 及更高版本禁用此限制。实际上,我已经将其用于应用程序,并希望尽快在 GitHub 上发布它。现在,这应该可以帮助您继续:
NSString *reqSysVer = @"6.0";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
// check if we are on >= iOS 6
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending) {
[ForgeApp sharedApp].webView.keyboardDisplayRequiresUserAction = NO;
[task success:nil];
}
else {
[task error:@"Invalid iOS version"];
}
在应用程序中调用插件方法一次后,您将能够在输入元素上使用普通的 .focus()。
关于ios - 如何在 iOS 上使用 Trigger.io 显示键盘而不需要用户操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17779719/