如何将此脚本安装到 PhoneGap for iOS 中
我不了解任何 Objective-C,这就是我使用 PhoneGap 来创建 iOS 应用程序的原因。 iOS 版 PhoneGap 存在一个很大的缺陷。键盘上经常有表单助手(“下一个”、“上一个”和“完成”按钮。)网上关于如何摆脱这个的信息很少,所有关于它的 Stackoverflow 问题都说它实际上是不可能的。但过了一段时间我偶然发现了这个教程。底部段落告诉您如何做到这一点。它有效,我下载并测试了完成的应用程序。
但由于我不知道如何在 Xcode 或 Objective-C 中执行几乎所有操作,因此我不知道这两部分代码会进入哪些文件,他在教程中没有说。
谁能告诉我它在 PhoneGap 应用程序文件中的位置?我非常感激,这已经困扰我一整天了。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
还有这个
RichTextEditorViewController *viewController = [[RichTextEditorViewController alloc] initWithNibName:@"RichTextEditorViewController" bundle:nil];
self.viewController = [[UINavigationController alloc] initWithRootViewController:viewController];
还有这个
- (void)removeBar {
// Locate non-UIWindow.
UIWindow *keyboardWindow = nil;
for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
if (![[testWindow class] isEqual:[UIWindow class]]) {
keyboardWindow = testWindow;
break;
}
}
// Locate UIWebFormView.
for (UIView *possibleFormView in [keyboardWindow subviews]) {
// iOS 5 sticks the UIWebFormView inside a UIPeripheralHostView.
if ([[possibleFormView description] rangeOfString:@"UIPeripheralHostView"].location != NSNotFound) {
for (UIView *subviewWhichIsPossibleFormView in [possibleFormView subviews]) {
if ([[subviewWhichIsPossibleFormView description] rangeOfString:@"UIWebFormAccessory"].location != NSNotFound) {
[subviewWhichIsPossibleFormView removeFromSuperview];
}
}
}
}
}
谢谢!
I don't know any Objective-C, that is why I'm using PhoneGap to create an iOS app. There is a big flaw in PhoneGap for iOS. The keyboard constantly has the form assistant (the 'next', 'previous' and 'done' buttons.) There is very little information on the web on how to get rid of this, all of the Stackoverflow questions about it said it was practically impossible. But after a while I stumbled upon this tutorial. The bottom paragraph tells you how to do it. And it works, I downloaded and tested the finished app.
But since I have no idea how to do almost anything in Xcode, or in Objective-C, I have no idea what files the two sections of code go into, he doesn't say in the tutorial.
Can anyone tell me where in the PhoneGap apps files it goes? I'd appreciate it massively, this has been bugging me all day.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
And this
RichTextEditorViewController *viewController = [[RichTextEditorViewController alloc] initWithNibName:@"RichTextEditorViewController" bundle:nil];
self.viewController = [[UINavigationController alloc] initWithRootViewController:viewController];
Also this
- (void)removeBar {
// Locate non-UIWindow.
UIWindow *keyboardWindow = nil;
for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
if (![[testWindow class] isEqual:[UIWindow class]]) {
keyboardWindow = testWindow;
break;
}
}
// Locate UIWebFormView.
for (UIView *possibleFormView in [keyboardWindow subviews]) {
// iOS 5 sticks the UIWebFormView inside a UIPeripheralHostView.
if ([[possibleFormView description] rangeOfString:@"UIPeripheralHostView"].location != NSNotFound) {
for (UIView *subviewWhichIsPossibleFormView in [possibleFormView subviews]) {
if ([[subviewWhichIsPossibleFormView description] rangeOfString:@"UIWebFormAccessory"].location != NSNotFound) {
[subviewWhichIsPossibleFormView removeFromSuperview];
}
}
}
}
}
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现自己需要这样做。我是一名 IOS 开发人员,但需要使用 PhoneGap 来降低多平台开发的成本。
无论如何,我修复了你的代码。因为,我猜,你不想花时间学习 obj-c,你只需要用以下内容替换 MainViewController.m 的内容:
作为警告,这是一个有点 hacky 的解决方案(但随后使用phonegap也是如此!),并且可能会在未来版本的iOS中中断。但我想我们会解决这个问题......
I have come across the need to do this myself. I am an IOS developer, but needed to use phonegap to keep costs down for multiplatform dev.
Anyway, i fixed your code. As, i guess, you dont want to spend your time learning obj-c, you just need to replace the contents of your MainViewController.m with the following:
As a word of warning, this is a bit of a hacky solution (but then so is using phonegap!), and may break in future versions of iOS. But i guess we fix that when it comes to it...
有许多 PhoneGap 插件可以增强键盘的控制。虽然我还没有使用过这个,但看起来离子键盘插件可能会提供您想要做的事情。
“隐藏带有下一个、上一个和完成按钮的键盘附件栏。”
方法:cordova.plugins.Keyboard.hideKeyboardAccessoryBar
添加它:
cordova插件添加 https://github.com/driftyco/ionic-plugins-keyboard.git< /a>
There are a number PhoneGap plugins to enhance control of the keyboard. Although I haven't used this yet it looks like the Ionic Keyboard Plugin may provide what you're trying to do.
"Hide the keyboard accessory bar with the next, previous and done buttons."
Method: cordova.plugins.Keyboard.hideKeyboardAccessoryBar
To add it:
cordova plugin add https://github.com/driftyco/ionic-plugins-keyboard.git