ninjinkun / njkwebviewprogress Goto Github PK
View Code? Open in Web Editor NEWUIWebView progress interface
License: MIT License
UIWebView progress interface
License: MIT License
Hi, how do I implement the NJKWebViewProgress into a custom Navigation Bar within my UIWebView programmatically? I can't seem to implement it into my view controller or Navigation Bar. Can you help?
为什么不能自己写进度条的颜色? 额 要是配合默认的白色 这个进度跳的颜色可以 但是实际开发中 不打可能都是这个配色 所以 进度条的颜色可设置还是比较重要的 虽然在源代码文件可以直接写 但是还是有 接口比较好 这是我的建议 谢谢
如果您的应用仍使用不推荐使用的UIWebView API嵌入网络内容,我们强烈建议您尽快更新到WKWebView,以提高安全性和可靠性。WKWebView通过将Web处理限制在应用程序的Web视图中,确保受损的Web内容不会影响应用程序的其余部分。iOS和macOS以及Mac Catalyst都支持它。
自2020年4月起,App Store将不再接受使用UIWebView的新应用程序,而自2020年12月起将不再接受使用UIWebView的应用程序更新。
Hey,
It seems to me that only http and https schemes are currently supported and this makes urls starting with file:// not work with the progress mechanism. Am I correct or missing something?
This could be useful for local HTML strings for example. Using a file instead of loadHTMLString:
Anyway I added this line of code and a pull request ready if needed ;)
BOOL isHTTPOrLocalFile = [request.URL.scheme isEqualToString:@"http"] || [request.URL.scheme isEqualToString:@"https"] || [request.URL.scheme isEqualToString:@"file"];
I am using NJKWebViewProgress to display page loading progress inside web browser. When loading large web pages (http://lifehacker.com for example) progress bar freezes for a long time and then, after the whole page appears, goes to 100%.
I saw your implementation - it tracks only page loading completion event. So, after some research I found the way to make progress more precise. It can be achieved by monitoring all AJAX requests (http://stackoverflow.com/questions/5353278/uiwebviewdelegate-not-monitoring-xmlhttprequest) on a page.
Even more, each AJAX request progress can be also monitored using progress event (https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest)
As far as I see, Facebook has already implemented it in their internal browser, as their loading progress works very smooth and precise while page is loading
What do you think about it?
waitForCompleteJS的执行加了后缀completeRPCURLPath,很显然这个请求不通,那么shouldStartLoadWithRequest方法中,就会执行[self completeProgress],并return NO。这样做的目的是什么?
i simply changed the "Deployment Target" to ios6.1 or earlier version, and the demo app build failed :(
"Property 'tintColor' not found on object of type 'UIWindow'" @NJKWebViewProgressView.m line 21-22
xcode 5.1
os 10.8.4
Here is my unit tests plan.
file://
test caseI believe the podfile isn't correct . it is pointing to "0.2.2" and some of the new features are missing
Hey @ninjinkun, this is a great library but I have noticed that you are not merging pull requests any more.
Perhaps you can add other maintainers who can merge them? :)
Is there any alternative in Swift?
The demo app which use storyboard to create the UIWebView
runs fine as follows.
However, if I change the UIWebView
to be created programmatically, some part of the view is below the navigation bar which cannot be seen. Following image shows the result.
Following code shows how the UIWebView
is created.
@implementation ViewController
{
// IBOutlet __weak UIWebView *_webView;
UIWebView *_webView;
NJKWebViewProgressView *_progressView;
NJKWebViewProgress *_progressProxy;
}
- (void)viewDidLoad
{
[super viewDidLoad];
_webView = [[UIWebView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.view addSubview:_webView];
......
}
On such web sites like: http://www.toysrus.com/ the component has issue with detecting load completion. It means that it never get 100% load indicator.
Please take a look on the screenshot.
Hello.
If you make a brand new project in Xcode, and add NJKWebViewProgress.h, it will fail to compile with:
/MyApp/SDKs/NJKWebViewProgress/NJKWebViewProgress.h:23:42: Cannot find protocol declaration for 'UIWebViewDelegate'
My guess is XCode now longer includes precompiled headers in new projects.
If you add <UIKit/UIKit.h>
to NJKWebViewProgress.h, it compiles fine.
//
// NJKWebViewProgress.h
//
// Created by Satoshi Aasano on 4/20/13.
// Copyright (c) 2013 Satoshi Asano. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
Thanks,
-- Jason
How to reproduce.
1.Clone master branch zip.
2.Open DemoApp.xcodeproj on Xcode 5.1(5B130a).
3.Run on iOS7.1 simulator.
Then i couldn't found progress view at view port.
On Xcode5.1 with iOS6.1 Simulator , i found progress view, well.
thanks.
How to use in WKWebView ?
how to set delegate (WKWebview have WKNavigationDelegate and WKUIDelegate)
你好,我在使用这个库的时候,发现我们的某些链接在UIWebview控件加载的过程中,进度条会卡到一半不动。请问这是怎么回事?(在iOS10,11上都有出现,只是针对我们自己的个别链接会这样,我们的链接是
http://registrationuat.gtdreamlife.com/#/openProject)。
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];
} Turn mainDocumentURL.host into an empty string or other domain name
i get a local html path and Appending a fragment #0 , for jump , but cant show this html
if a html contains of the operation for hash changed,the progress maybe never finish.
Is there any way to change the color of the bar?
I found only a way to change the background color.
I would appreciate your advice.
_progressProxy = [[NJKWebViewProgress alloc] init]; // instance variable
webView.delegate = _progressProxy
Apparently, WKWebView doesn't have a delegate .
How do you use NJKWebViewProgress with WKWebView?
in my dealloc i do
self.loadingProgress.webViewProxyDelegate = nil;
self.loadingProgress.progressDelegate = nil;
self.loadingProgress = nil;
[self.webView loadHTMLString:@"" baseURL:nil];
[self.webView stopLoading];
self.webView.delegate = nil;
[self.webView removeFromSuperview];
but still i'am getting incrementing memory when loading a new webview... by not using NJKWebViewProgress i get a steady memory use... looks like there is some stonrg refference to the webview which doesn't allow it to be fred
Hi,
I'm trying to use the NJKWebViewProgressView
as progress on a UIView
like:
- (void)viewDidLoad {
CGFloat progressBarHeight = 2.f;
CGRect navigaitonBarBounds = self.view.bounds;
CGRect barFrame = CGRectMake(0, progressBarHeight + 5.0 , navigaitonBarBounds.size.width, progressBarHeight);
_progressView = [[NJKWebViewProgressView alloc] initWithFrame:barFrame];
_progressView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
[_progressView setProgress:0.2 animated:NO];
[self.container addSubview:_progressView];
//...
so without having any UIWebView
delegate and trying to update the progress manually. If I try to change the progress it seems nothing happens a part in the viewDidLoad
method:
-(IBAction)discover:(id)sender {
float progress=0.5;
dispatch_async(dispatch_get_main_queue(), ^{
[_progressView setProgress:progress animated:YES];
});
where self.container
is a UIView
.
Where I'm wrong or missing something in the code?
In the FirstLoad , the html want to fragment jump, and now web.request is null, you cannot compare nonFragmentURL to webView.request.URL.absoluteString to a null string.
Hope to support - (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL
method
then load request ,the progressBar go forward
when some page load finish ,it can't call webViewDidFinishLoad method and the progress is always 0.1
Try accessing "http://www.koreanpalace.com/". The server isn't found but
BOOL isNotRedirect = _currentURL && [_currentURL isEqual:webView.request.mainDocumentURL];
isn't YES
because webView.request.mainDocumentURL
is nil
.
Hi ninjinkun:
I run the demo on both device and simulator, but I found that no matter what page I request, the progress returned always be 0.0 0.1 0.5 or 1.0.
Why there are only the 0.0 0.1 0.5 and 1.0 four state of progress?
Best Regards :D
Error Domain=NSURLErrorDomain Code=-1005 "网络连接已中断。" UserInfo=0x164d3310 {NSErrorFailingURLStringKey=http://cn.wsj.com/gb/20140723/PHO100342.asp, NSErrorFailingURLKey=http://cn.wsj.com/gb/20140723/PHO100342.asp, NSLocalizedDescription=网络连接已中断。, NSUnderlyingError=0x1657a3c0 "网络连接已中断。"}
when i click ,It did not react
when i load a webview with rich text ,when i click,There is no cursor, but when I shield the progress bar code, click it will be edited.How can i do?Can you help me ?
Hello,
I think your control is great and would love to use it but some new sites (airbnb on iPad iOS 8.0) gets stuck at 50%.
Could you please have a look, or maybe point out what goes wrong.
Thanks,
R.
"BOOL isNotRedirect = _currentURL && [_currentURL isEqual:webView.request.mainDocumentURL]" should be "BOOL isNotRedirect = _currentURL && [_currentURL isEqual:webView.request.URL];" in "- (void)webViewDidFinishLoad:(UIWebView *)webView" and "- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error".
In the incrementProgress method, two line code confuse me.
I think
float maxProgress = _interactive ? NJKFinalProgressValue : NJKInteractiveProgressValue;
should be
float maxProgress = _interactive ? NJKInteractiveProgressValue: NJKFinalProgressValue;
and
float increment = (maxProgress - progress) * remainPercent;
should be
float increment = (maxProgress - progress) * (1-remainPercent);
Do I think wrong?
Next to the issue #11 dealing with device rotation, NJKWebViewProgress lacks a possibility to set a custom bar color by code (i.e. the color showing the progress, here: defaults to blue).
Compared to https://github.com/MobileMakersAcademy/SuProgress where I can override the progress animation color by a simple:
[self.SuProgressBar setBackgroundColor:[UIColor greenColor]];
Sticking for now to SuProgress, but I like the idea of using NJKWebViewProgress together with NJKScrollFullSreen to implement a safari-like iOS7 UX.
Why can't write their own progress bar color?The forehead If the default white The progress of color can be But in the actual development Don't play may be the color So the color of the progress bar can be set up was more important Although can write directly in the source code file But there are still interface is better This is my suggestion Thank you very much
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.