li6185377 / imywebview Goto Github PK
View Code? Open in Web Editor NEWReplace UIWebView to WKWebView
License: MIT License
Replace UIWebView to WKWebView
License: MIT License
JSContext * context = [(UIWebView *)webView.realWebView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
NSString * alertJS = @"alert('test js OC')"; //准备执行的js代码
[context evaluateScript:alertJS];
崩在第一句
(WKWebViewConfiguration*)configuration
{
WKWebViewConfiguration* configuration = [[NSClassFromString(@"WKWebViewConfiguration") alloc] init];
configuration.userContentController = [NSClassFromString(@"WKUserContentController") new];
WKPreferences* preferences = [NSClassFromString(@"WKPreferences") new];
preferences.javaScriptCanOpenWindowsAutomatically = YES;
configuration.preferences = preferences;
return configuration;
}
wkWebView 实现UIDelegate 等代理方法后 例如runJavaScriptAlertPanelWithMessage ,在某些特定场合会崩溃,例如wKwebview 执行js alert时,wkWebview的控制器有push或present 动画未完成时会崩溃。 请问你是怎么处理的
有个需求是算出web的高度,要再后面add一个UIView,IOS7的话,在- (void)webViewDidFinishLoad:(IMYWebView *)webView之后获取到的webView.scrollView.contentSize有值,IOS8之后获取到的为0.
你好 不能完全适配,比如与js交互问题,uiwebView有jscontext来注册js回来调用方法,但是wkwebView没有 这个怎么处理呢
我看项目中copy了NJKWebViewProgress 的部分代码,为什么不直接用Pod 引用?
要是copy了,把NJKWebViewProgressView 也copy一份啊!现在我手动加入 NJKWebViewProgress 的库,还出现 completeRPCURL 变量符号冲突。
我们的程序目前兼容iOS7 想 iOS7用uiwebview iOS8 用wkwebivew 。 你的这个demo 里第一次加载是webview吧 第二次 加载才用的是wkwebview 。 我们应用中有一个全是图片的html 高度 5w多。 测试手机6plus 测试结果 使用UIWebview 内存挂掉。 使用wkwebview
内容加载不出来。 计算高度采用的是添加观察者。
[WebActionDisablingCALayerDelegate willBeRemoved]: unrecognized selector sent to instance 0x60000000da70
请问,有人遇到过这个错误吗,如何解决?
后台统计发现 ios12 有部分闪退 都是
WebCore | WebCore::FrameLoader::checkCompleted() + 592 |
---|---|
1 WebCore | WebCore::FrameLoader::init() + 740 |
2 WebCore | WebCore::FrameLoader::init() + 740 |
3 WebKitLegacy | +[WebFrame(WebInternal) _createMainFrameWithPage:frameName:frameView:] + 332 |
4 WebKitLegacy | -[WebView(WebPrivate) _commonInitializationWithFrameName:groupName:] + 2924 |
5 WebKitLegacy | -[WebView(WebPrivate) _initWithFrame:frameName:groupName:] + 132 |
6 UIKitCore | -[UIWebDocumentView initWithWebView:frame:] + 320 |
7 UIKitCore | -[UIWebBrowserView initWithWebView:frame:] + 48 |
8 UIKitCore | -[UIWebBrowserView initWithFrame:] + 44 |
9 UIKitCore | -[UIWebView _webViewCommonInitWithWebView:scalesPageToFit:] + 244 |
10 UIKitCore | -[UIWebView initWithFrame:] + 76 |
11 TfClient | -[IMYWebView initUIWebView] (IMYWebView.m:134) |
12 TfClient | -[IMYWebView _initMyself] (IMYWebView.m:92) |
知道是什么原因吗
-(void)setScalesPageToFit:(BOOL)scalesPageToFit
把上面个方法中的 那段js代码删掉 就好了 ,因为淘宝的页面 已经包含了viewport mate标签,并且 witdh= 0.333 , 你那段js改成了witdh= 1. 。。。 所以 放大了
-(void)setScalesPageToFit:(BOOL)scalesPageToFit;
NSMutableArray* array = [NSMutableArray arrayWithArray:webView.configuration.userContentController.userScripts];
for (WKUserScript *wkUScript in array)
{
if([wkUScript.source isEqual:jScript])
{
[array removeObject:wkUScript];
break;
}
}
for (WKUserScript *wkUScript in array)
{
[webView.configuration.userContentController addUserScript:wkUScript];
}
这一段存在bug
在for之前需要加入
[webView.configuration.userContentController removeAllUserScripts];
不然没有移除相关的js
你好,我想问一下。wkwebview怎么传值给h5 让h5调用本地传的值
加载word的doc文件 无法自适应大小scalesPageToFit
UIWebView可以从
valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"
拿到jscontext,但WKWebView要从
- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message;
回调里面拿到js的信息,完全是两种不同的用法,有办法统一吗
IMYWebView中使用那些系统热更新关键字了吗? 现在审核不过了
并不是真的网络请求的进度吧?而是用0.5 0.9去代替?
请问这个如何适配https ?
[config.userContentController addScriptMessageHandler:self name:@"xxx"];可能会对self强引用造成内存泄露,在removeScriptMessageHandlerForName之后可以解决这个问题但是删除之后再次添加 就调不起js了有什么 好的解决办法没有。
*** Terminating app due to uncaught exception 'BadWebViewType', reason: 'Unknown web view type.'
*** First throw call stack:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.