- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
因此从这个线程改编代码 UIKeyboardAppearance in UIWebView和 TomSwift's很棒的答案,我得到了大约 99% 的答案。
在 iOS 7 模拟器中,一切似乎都运行良好。然而在 iOS 8 中,当键盘第一次出现时,< > 完成栏是白色的。当我点击或选择另一个输入时,它会更改为我指定的颜色。
我的问题是,如何防止和/或更改该白色部分?
其他线程中的所有代码都是相同的,除了我在 keyboardWillAppear 中这样调用的颜色。
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]) {
if ([[possibleFormView description] hasPrefix : @"<UIInputSetContainerView"]) {
for (UIView* peripheralView in possibleFormView.subviews) {
peripheralView.backgroundColor = [UIColor colorWithRed:0.271 green:0.271 blue:0.271 alpha:0.75];
for (UIView* peripheralView_sub in peripheralView.subviews) {
peripheralView_sub.backgroundColor = [UIColor colorWithRed:0.271 green:0.271 blue:0.271 alpha:0.75];
}
}
}
}
如有任何帮助,我们将不胜感激。
最佳答案
所以随着 iOS 9+ 的发布,我发现它破坏了上述方法。但是通过一些修补和查看一些观点,我想出了一个补充我已经在下面回答的内容。
现在我决定放弃自定义颜色的东西,我正在挖掘适合我的应用程序的黑色键盘。无论如何,这对我有用。在 9.1 sim 到 7 上测试。也在我的 6+ 上运行 9.0.2。
//Keyboard setting
@interface UIWebBrowserView : UIView
@end
@interface UIWebBrowserView (UIWebBrowserView_Additions)
@end
@implementation UIWebBrowserView (UIWebBrowserView_Additions)
- (id)inputAccessoryView {
return nil;
}
- (UIKeyboardAppearance) keyboardAppearance{
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
BOOL switchOn = [userDefaults boolForKey:@"darkKeyboard"];
if (switchOn) {
return UIKeyboardAppearanceDark;
}
else {
return UIKeyboardAppearanceDefault;
}
}
@end
@interface UITextInputTraits : UIWebBrowserView
@end
@interface UITextInputTraits (UIWebBrowserView)
@end
@implementation UITextInputTraits (UIWebBrowserView)
- (UIKeyboardAppearance) keyboardAppearance{
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
BOOL switchOn = [userDefaults boolForKey:@"darkKeyboard"];
if (switchOn) {
return UIKeyboardAppearanceDark;
}
else {
return UIKeyboardAppearanceDefault;
}
}
@end
我真的希望有人觉得这些答案有帮助 :D
更新信息:对完成栏很好奇,这就是这一切的开始。我重新启用它只是为了看看,发现它把它变成了黑色。不错的奖励,尽管我放弃了它以使用滚动隐藏键盘。
15 年 12 月 19 日更新所以我决定从 UIWebView 过渡到 WKWebView,结果发现两者之间显然有所不同。我设法让它再次工作。常规的 UIKeyboardAppearanceDark 调用会导致键盘比我喜欢的更透明。所以我根据自己的喜好修改了它。同样,这可能不是标准的做事方式,但我不在乎,反正它不会成为苹果。
所有内容仍在 AppDelegate 中。
//Removing the input bar above the keyboard.
@interface InputHider : NSObject @end
@implementation InputHider
-(id)inputAccessoryView{
return nil;
}
@end
@interface UIWebBrowserView : NSObject
@end
@interface NSObject (UIWebBrowserView_Additions)
@end
@implementation NSObject (UIWebBrowserView_Additions)
- (UIKeyboardAppearance) keyboardAppearance{
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
BOOL switchOn = [userDefaults boolForKey:@"darkKeyboard"];
if (switchOn) {
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]) {
if ([possibleFormView isKindOfClass:NSClassFromString(@"UIInputSetContainerView")] ||
[possibleFormView isKindOfClass:NSClassFromString(@"UIInputSetHostView")]) {
for (UIView* peripheralView in possibleFormView.subviews) {
peripheralView.backgroundColor = [UIColor colorWithRed:0.271 green:0.271 blue:0.271 alpha:1.0];
//Keyboard background
for (UIView* peripheralView_sub in peripheralView.subviews) {
peripheralView_sub.backgroundColor = [UIColor colorWithRed:0.271 green:0.271 blue:0.271 alpha:1.0];
//Accessory bar color
if ([possibleFormView isKindOfClass:NSClassFromString(@"WKContentView")]) {
for (UIView* UIInputViewContent_sub in peripheralView_sub.subviews) {
[[UIInputViewContent_sub layer] setOpacity : 1.0];
UIInputViewContent_sub.backgroundColor = [UIColor colorWithRed:0.271 green:0.271 blue:0.271 alpha:1.0];
}
}
}
}
}
}
return UIKeyboardAppearanceDark;
}
else {
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]) {
if ([possibleFormView isKindOfClass:NSClassFromString(@"UIInputSetContainerView")] || [possibleFormView isKindOfClass:NSClassFromString(@"UIKeyboard")]) {
for (UIView* peripheralView in possibleFormView.subviews) {
peripheralView.backgroundColor = [UIColor clearColor];
//Keyboard background
for (UIView* peripheralView_sub in peripheralView.subviews) {
peripheralView_sub.backgroundColor = [UIColor clearColor];
//Accessory bar color
if ([possibleFormView isKindOfClass:NSClassFromString(@"UIWebFormAccessory")]) {
for (UIView* UIInputViewContent_sub in peripheralView_sub.subviews) {
[[UIInputViewContent_sub layer] setOpacity : 1.0];
UIInputViewContent_sub.backgroundColor = [UIColor clearColor];
}
}
}
}
}
}
return UIKeyboardAppearanceDefault;
}
}
@end
@interface UITextInputTraits : UIWebBrowserView
@end
@interface UITextInputTraits (UIWebBrowserView)
@end
@implementation UITextInputTraits (UIWebBrowserView)
- (UIKeyboardAppearance) keyboardAppearance{
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
BOOL switchOn = [userDefaults boolForKey:@"darkKeyboard"];
if (switchOn) {
return UIKeyboardAppearanceDark;
}
else {
return UIKeyboardAppearanceDefault;
}
}
@end
//Disables endDisablingInterfaceAutorotationAnimated error for keyboard
@interface UIWindow (UIWebBrowserView)
- (void)beginDisablingInterfaceAutorotation;
- (void)endDisablingInterfaceAutorotation;
@end
@implementation UIWindow (UIWebBrowserView)
- (void)beginDisablingInterfaceAutorotation {}
- (void)endDisablingInterfaceAutorotation{}
@end
我还没有像以前那样设法找到隐藏 inputAccessoryBar 的方法,但多亏了几个线程,我才让它工作。在我的 View Controller 中,我调用:
-(void)removeInputAccessoryView {
UIView* subview;
for (UIView* view in webView.scrollView.subviews) {
if([[view.class description] hasPrefix:@"WKContent"])
subview = view;
}
if(subview == nil) return;
NSString* name = [NSString stringWithFormat:@"%@SwizzleHelper", subview.class.superclass];
Class newClass = NSClassFromString(name);
if(newClass == nil)
{
newClass = objc_allocateClassPair(subview.class, [name cStringUsingEncoding:NSASCIIStringEncoding], 0);
if(!newClass) return;
Method method = class_getInstanceMethod([AppDelegate class], @selector(inputAccessoryView));
class_addMethod(newClass, @selector(inputAccessoryView), method_getImplementation(method), method_getTypeEncoding(method));
objc_registerClassPair(newClass);
}
object_setClass(subview, newClass);
}
在我调用的 viewDidLoad 中:
[self removeInputAccessoryView];
我计划再进行一些修补,但就目前而言,它可以满足我的需要。
关于ios - 自定义 webview 键盘问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28664984/
Webview shouldInterceptRequest方法总是返回null。我去了adblocking的use方法。我尝试了很多adblock方法,但是总是需要这个shouldIntercept
在我的 Native React 项目中,我想使用 WebView。 HTML是指外部的css文件,css文件是指一些自定义字体。 鉴于此层次结构: app/ app/index.ios.js app
我在一个页面上有多个 webview,当应用程序加载时,主页面卡住了将近 8-10 秒,我猜测这是所有 webview 加载各自网站所花费的时间,为什么 Ui 卡住了,我怎么能使 webview 加载
nativescript 中的 webview 是否有“导航”事件? 我已经在 Xamarin (c#) 中用 完成了 Browser.Navigating += Myfunction natives
我的浏览器 (webview) 以 HTML 页面开头 FILEJAVA.class.getResource ("FILEHTML.html")。 ToExternalForm () 每当我访问谷歌时
我们正在开发一个 JavaFX 2.x 应用程序,它需要提供一些 GIS 支持。我们得出的结论是,通过嵌入式 WebView 使用 GoogleMaps 是最快的选择。它的问题在于每次我们的应用程序启
有没有办法销毁 WebView 实例?如果页面加载,并说视频开始播放,我希望能够,当我隐藏 WebView 时,基本上可以销毁它,或者至少重置它。 我知道我可以听 visibleProperty 并执
有没有办法在不启用远程模块的情况下在 webview 和主窗口之间进行通信? When this attribute is false the guest page in webview will
我使用以下代码来拦截Web View 中的对话框,但看不到内容或无法与之交互: Element webview= querySelector("#webview"); Map map=new
我正在创建一个页面,该页面将在 Java 的 WebView 中打开,或在外部浏览器中手动打开。如果页面是从 Java 加载的——我需要它来执行特定的回调,因为 Java 被用作一种后端,但如果页面是
我有一个 React Native WebView ,它运行一个小的 HTML 文档。该文档显示了一些图像。 我希望显示位于应用程序的 Documents 文件夹中的图像,即图像不是静态 Assets
我正在使用 JavaFX webview 开发一个网络爬虫。出于抓取目的,我不需要加载图像。当页面被加载时,Webkit 会产生很多 UrlLoader 线程。所以我认为最好禁用图像,这样我会节省很多
这个问题在这里已经有了答案: Android webview launches browser when calling loadurl (11 个答案) 关闭 7 年前。 我花了两天的时间来寻找一
我正在加载一个网页,我想使用基本身份验证登录,我有使用 Swift 的经验并且能够像下面那样执行基本身份验证,但我无法为我的应用程序的 Flutter 版本实现基本身份验证。 ---- swift 代
我用 webview 创建了应用程序,我想在 webview 中加载所有内部链接并在 android 浏览器中加载外部链接。现在的问题是我正在使用 html 广告,当我点击广告时我想打开外部浏览器,但
我需要在父背景图案上显示我的 webview 内容。有没有直接的方法来做到这一点? 最佳答案 这可能有用 final com.sun.webkit.WebPage webPage = com.sun.
是否可以从 webview 中加载的页面读取 http 请求和响应数据。我想要做的是在用户单击 webview 中页面内的链接后从响应中获取二进制数据。任何帮助或线索将不胜感激 最佳答案 创建您自己的
我有一个简单的WebView在 Android 上运行 Web 应用程序。问题是当我旋转手机以将其更改为横向 webview重新加载并回到开头。 我怎样才能防止这种行为? 罗恩 最佳答案 从 Andr
我创建了一个带有 webview 标签的自定义浏览器。当我在 google.it(或 google.com)中导航时,有时会出现一条消息说 chrome 已过时。我的应用版本是: Node.js 8.
我正在使用 Electron 创建简单的网络浏览器。我的用例是我需要通过不同/各自的代理 IP 路由每个 URL。如果用户输入 google.com,则必须通过 123.123.122.1:8081
我是一名优秀的程序员,十分优秀!