Comments (3)
I checked this issues running on iOS 7.1 (built with 7.1 SDK).
Here it works fine so I guess something changed in 8.
I will try to figure it out myself, might take a while, but I would enormously appreciate your help.
Thanks,
Roland
from njkwebviewprogress.
Did you happen to find a good fix? I am about to go home, but I've stumbled over the same problem. I think the problem is here:
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
if ([_webViewProxyDelegate respondsToSelector:@selector(webViewDidFinishLoad:)]) {
[_webViewProxyDelegate webViewDidFinishLoad:webView];
}
_loadingCount--;
[self incrementProgress];
NSString *readyState = [webView stringByEvaluatingJavaScriptFromString:@"document.readyState"];
BOOL interactive = [readyState isEqualToString:@"interactive"];
if (interactive) {
_interactive = YES;
NSString *waitForCompleteJS = [NSString stringWithFormat:@"window.addEventListener('load',function() { var iframe = document.createElement('iframe'); iframe.style.display = 'none'; iframe.src = '%@://%@%@'; document.body.appendChild(iframe); }, false);", webView.request.mainDocumentURL.scheme, webView.request.mainDocumentURL.host, completeRPCURLPath];
[webView stringByEvaluatingJavaScriptFromString:waitForCompleteJS];
}
BOOL isNotRedirect = _currentURL && [_currentURL isEqual:webView.request.mainDocumentURL];
BOOL complete = [readyState isEqualToString:@"complete"];
if (complete && isNotRedirect) {
[self completeProgress];
}
}
specifically this line:
BOOL isNotRedirect = _currentURL && [_currentURL isEqual:webView.request.mainDocumentURL];
I've noticed that in my case, the URL is changed (probably by Javascript), after the hash sign. Thus isNotRedirect
was false.
I'm going home now and I don't know if this is a clean fix or even a fix, but it appears to work now for me using this code:
BOOL isNotRedirect = YES;
if (_currentURL != nil && _currentURL.fragment != nil) {
NSString *nonFragmentCurrentURL = [_currentURL.absoluteString stringByReplacingOccurrencesOfString:[@"#" stringByAppendingString:_currentURL.fragment] withString:@""];
NSString *nonFragmentMainDocumentURL = [webView.request.mainDocumentURL.absoluteString stringByReplacingOccurrencesOfString:[@"#" stringByAppendingString:webView.request.mainDocumentURL.fragment] withString:@""];
isNotRedirect = _currentURL && [nonFragmentCurrentURL isEqual:nonFragmentMainDocumentURL];
}
To detect the redirect I use the URLs without the fragment.
from njkwebviewprogress.
Here is a pull request for a fix: #58
from njkwebviewprogress.
Related Issues (20)
- when I start up my App ,it's crash? HOT 1
- Swift Alternative HOT 1
- Can't load complete on iOS8
- why I entry controller first show the whole progressBar?
- isFragmentJump In the FirstLoad Maybe has something wrong
- 为什么不能自己写进度条的颜色 HOT 1
- It seems to have conflict with the rich text loaded with WebView
- It seems to have conflict with WebViewJavascriptBridge HOT 2
- 为什么增加waitForCompleteJS
- loadlocalHTML,have a Fragment#0, but cant show
- Add maintainers? HOT 1
- Why can't write their own progress bar color?
- bug (click a link and then go back and then click the link again, it may cause progress never complete )
- Expand unit tests
- How to use in WKWebView ? HOT 1
- 还更新吗? HOT 3
- the progress never finish! HOT 1
- 有些链接进度条一直卡到一半不动了
- bug(njkwebviewprogressproxy/complete)404
- Updating Apps that Use Web Views HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from njkwebviewprogress.