Phonegap iOS6:删除表单助手栏的正确解决方案(上一个,下一个,完成)

时间:2023-02-16
本文介绍了Phonegap iOS6:删除表单助手栏的正确解决方案(上一个,下一个,完成)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

另一个如何删除 pre、next、done 按钮"-你可能会想到的问题.其实不是.我对此进行了一些相当彻底的研究并尝试了不同的方法,但似乎没有任何方法或解决方案真正正确.下面提到和显示的所有解决方法(就是它们)基本上是相同的方法,替换 MainViewController.m 文件的内容.我很清楚所有这些提议的解决方案或多或少都有点hacky,但仍然应该有有人以一点优雅和深思熟虑解决了这个问题,或者熟悉 C 并且可以提出更可靠的解决方案的人.

Another "how to remove the pre, next, done button" -question you may think. Not really actually. I've done some rather thorough research on this and tried out different approaches but no method or solution really seems to do it right. All workaround (that's what they are) mentioned and shown below are basically the same approach, replace content of the MainViewController.m file. I'm well aware of that more or less all these proposed solutions are somewhat hacky but still, there should be someone out there who has tackled this issue with a little bit of grace and deep thought, or someone who knows C well and can propose a more solid solution.

请允许我通过引用一些建议的解决方案来说明我的观点:

Allow me to illustrate my point by making references to some proposed solutions:

在 iOS6 中,这会导致 表单助手栏边框仍然存在,并且键盘的行为就像表单助手栏仍然存在一样.

In iOS6, this results in the form assistant bar border still being present and the keyboard acting as if the form assistant bar were still there.

有人提出了上述问题的解决方案,但我根本无法让它发挥作用.回答者对帖子进行了多次编辑和评论,这只会让您更难掌握在哪里做什么.我已经尝试了他解决方案的所有变体,但我总是遇到严重错误,而项目只是无法编译.

Someone proposed a solution to the above but I simply cannot get it to work. The answerer has made several edits and comments to the post which only make harder to grasp what to do where. I've tried all variations of his solution but I always end up getting a critical error and the project simply wont compile.

不是 C 程序员(这就是我使用 phonegap 的原因)所以不能让它正常工作.不知道在哪里添加什么.

Not a C programmer (that's why I use phonegap) so can't get this to work properly. Don't know what to add where.

不知道在哪里以及如何实现这一点,所以没有尝试过.我应该在哪里注册以接收keyboardDidShow 通知?我应该在哪里添加该功能?

Don't know where and how to implement this so haven't tried it. Where should I register to receive the keyboardDidShow notification? Where should I add the function?

根据我的研究,如果您愿意的话,目前还没有人提出适当的解决方案.那么有没有人成功删除表单助手而没有上述任何副作用?

According to my research, if you will, no one has yet proposed a proper solution to this. So has anyone successfully removed the form assistant without any of the above mentioned side effects?

推荐答案

给你,我正在我正在开发的应用程序中使用它.祈祷它可以进入应用商店,尽管通过其他黑客"进入商店这并不比其他人差,所以应该有一个公平的机会.

Here you go, I'm using this in an app I'm currently developing. Fingers crossed that it gets to the app store, although going on other 'hacks' that make it to the store this is no worse than others, so should stand a fair chance.

这种方法没有烦人的副作用 - 它通过确保从一开始就从未创建它来干净地删除栏.哒哒!

No annoying side effects with this method - it cleanly removes the bar by making sure it's never created in the first place. Ta da!

感谢 https://gist.github.com/2048571,这是他的代码,有一个小修复.

Credit goes to https://gist.github.com/2048571, this is his code with a small fix.

#import <objc/runtime.h>
#import <UIKit/UIKit.h>

@interface UIWebView (HackishAccessoryHiding)
@property (nonatomic, assign) BOOL hackishlyHidesInputAccessoryView;
@end

@implementation UIWebView (HackishAccessoryHiding)

static const char * const hackishFixClassName = "UIWebBrowserViewMinusAccessoryView";
static Class hackishFixClass = Nil;

- (UIView *)hackishlyFoundBrowserView {
    UIScrollView *scrollView = self.scrollView;

    UIView *browserView = nil;
    for (UIView *subview in scrollView.subviews) {
        if ([NSStringFromClass([subview class]) hasPrefix:@"UIWebBrowserView"]) {
            browserView = subview;
            break;
        }
    }
    return browserView;
}

- (id)methodReturningNil {
    return nil;
}

- (void)ensureHackishSubclassExistsOfBrowserViewClass:(Class)browserViewClass {
    if (!hackishFixClass) {
        Class newClass = objc_allocateClassPair(browserViewClass, hackishFixClassName, 0);
        IMP nilImp = [self methodForSelector:@selector(methodReturningNil)];
        class_addMethod(newClass, @selector(inputAccessoryView), nilImp, "@@:");
        objc_registerClassPair(newClass);

        hackishFixClass = newClass;
    }
}

- (BOOL) hackishlyHidesInputAccessoryView {
    UIView *browserView = [self hackishlyFoundBrowserView];
    return [browserView class] == hackishFixClass;
}

- (void) setHackishlyHidesInputAccessoryView:(BOOL)value {
    UIView *browserView = [self hackishlyFoundBrowserView];
    if (browserView == nil) {
        return;
    }
    [self ensureHackishSubclassExistsOfBrowserViewClass:[browserView class]];

    if (value) {
        object_setClass(browserView, hackishFixClass);
    }
    else {
        Class normalClass = objc_getClass("UIWebBrowserView");
        object_setClass(browserView, normalClass);
    }
    [browserView reloadInputViews];
}

@end

这篇关于Phonegap iOS6:删除表单助手栏的正确解决方案(上一个,下一个,完成)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:android:显示虚拟键盘时如何防止调整窗口大小 下一篇:Android 3.1 软键盘全屏模式

相关文章

最新文章