本文介绍了如何解决iOS上的Cordova 3.1键盘问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我刚刚使用示例iOS应用程序测试了 Cordova 3.1 ,并遇到了几个键盘问题。 应用设置: Xcode 5 隐藏状态栏 横向模式 config.xml b $ b 问题: 所有版本:当关注输入字段时, iOS5 / 6:点击输入字段以打开键盘,然后在屏幕顶部短暂显示黑色间隙,是否为状态栏?) iOS7:没有像#2这样的黑名单,但还有其他问题: 我仍然在删除(隐藏)前看到配件栏。 如果我改变了,情况就更糟了: 视图仍然向上推,焦点,那么一个黑色的间隙闪烁在屏幕的顶部,即使在iOS 7,如果KeyboardShrinksView = false不会发生。 键盘不再在iOS 7上是半透明的。 下面是我的config.xml < preference name =DisallowOverscrollvalue =true/> < preference name =HideKeyboardFormAccessoryBarvalue =true/> < preference name =KeyboardDisplayRequiresUserActionvalue =false/> < preference name =KeyboardShrinksViewvalue =true/> < preference name =SuppressesIncrementalRenderingvalue =false/> < preference name =TopActivityIndicatorvalue =grey/> < preference name =EnableLocationvalue =false/> < preference name =EnableViewportScalevalue =false/> < preference name =AutoHideSplashScreenvalue =false/> < preference name =ShowSplashScreenSpinnervalue =false/> < preference name =MediaPlaybackRequiresUserActionvalue =false/> < preference name =AllowInlineMediaPlaybackvalue =false/> < preference name =BackupWebStoragevalue =none/> < preference name =Fullscreenvalue =true/> < preference name =Orientationvalue =landscape/> 解决方案在这里报告了很多相同的问题。这将是最好的,如果你添加您的信息到Cordova JIRA错误跟踪系统,因为那是所有cordova开发人员工作的地方。 https://issues.apache.org/jira/browse/CB-3020?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13769996#comment -13769996 我可以通过添加一个简单的动画来调整webview的大小来获得顶部标题。下面是放在CDViewController.m中的keyboardWillShow函数中的代码 [UIView beginAnimations:nil context:NULL] [UIView setAnimationDuration:1.0]; [self.webView setFrame:(CGRectMake(newFrame.origin.x,newFrame.origin.y,newFrame.size.width,newFrame.size.height))]; [UIView commitAnimations]; 我接近让黑条被隐藏,但不能让它工作得很好。这篇文章描述了你需要做什么。你需要hae webview reizing动画匹配键盘动画。 iOS 7 - 键盘动画 I just tested Cordova 3.1 with a sample iOS app and experienced several keyboard issues.App settings:Xcode 5Status bar is hiddenLandscape modeconfig.xmlIssues:All versions: when focus on an input field then whole view is pushed up including navbar.iOS5/6: tap on an input field to open keyboard, then a black gap is briefly displayed at top of screen before keyboard pushes whole view up (is it status bar?)iOS7: there is no black gap like #2 issue, but there are other issues:I still see accessories bar before it's removed (hidden).Keyboard is translucent then I can see darker background in the space where current view is pushed up.If I changed , things are even worse:View is still pushed up, and when input field loses focus then a black gap is flickring at the top of screen, even on iOS 7, what doesn't happen if KeyboardShrinksView = false.Keyboard is no longer translucent on iOS 7.Below is my config.xml<preference name="DisallowOverscroll" value="true" /> <preference name="HideKeyboardFormAccessoryBar" value="true" /> <preference name="KeyboardDisplayRequiresUserAction" value="false" /> <preference name="KeyboardShrinksView" value="true" /> <preference name="SuppressesIncrementalRendering" value="false" /> <preference name="TopActivityIndicator" value="gray" /> <preference name="EnableLocation" value="false" /> <preference name="EnableViewportScale" value="false" /> <preference name="AutoHideSplashScreen" value="false" /> <preference name="ShowSplashScreenSpinner" value="false" /> <preference name="MediaPlaybackRequiresUserAction" value="false" /> <preference name="AllowInlineMediaPlayback" value="false" /> <preference name="BackupWebStorage" value="none" /> <preference name="Fullscreen" value="true" /> <preference name="Orientation" value="landscape" /> 解决方案 Check out this thread. A lot of the same issues were reported here. It would be best if you added your information to the Cordova JIRA bug tracking system since that's where all the cordova developers work out of.https://issues.apache.org/jira/browse/CB-3020?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13769996#comment-13769996I was able to get the top header from sliding around by adding in a simple animation to the resizing of the webview. Here is the code that was put in the keyboardWillShow function in CDViewController.m[UIView beginAnimations:nil context:NULL];[UIView setAnimationDuration:1.0];[self.webView setFrame:(CGRectMake(newFrame.origin.x, newFrame.origin.y, newFrame.size.width, newFrame.size.height))];[UIView commitAnimations];I was close to getting the black bar from being hidden but couldn't get it working very well. This post describes what you will need to do. You'll need to hae the webview reizing animation match the keyboard animation.iOS 7 - Keyboard animation 这篇关于如何解决iOS上的Cordova 3.1键盘问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-13 14:31