問題描述
另一個如何刪除 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:刪除表單助手欄的正確解決方案(上一個,下一個,完成)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!