如何查找UIWebView的最后一个负载(就绪状态4)

UIWebView中的didFinishLoad方法存在问题,它一直在触发。 我想尝试estimatedProgress 解决scheme ,但是我不知道在哪里find这些框架不幸的。 我正在运行Mountain Lion并使用最新版本的XCode。 此外,对于UIWebView多次发射,这是最好的方式去或有新的方法。 这似乎是一个JavaScript的答案 ,但是这并不适用于我。 那是在2009年,我听说苹果拒绝任何使用私有API的应用程序。 请帮我在这里!

谢谢大家!

跟踪未完成请求的数量呢? 我掀起了一些似乎工作的testing代码:

 @interface WebViewDelegate : NSObject<UIWebViewDelegate> @property ( nonatomic ) NSUInteger numberOfRunningRequests ; @end @implementation WebViewDelegate -(void)webViewDidStartLoad:(UIWebView *)webView { self.numberOfRunningRequests = self.numberOfRunningRequests + 1 ; } -(void)webViewDidFinishLoad:(UIWebView *)webView { self.numberOfRunningRequests = self.numberOfRunningRequests - 1 ; if ( self.numberOfRunningRequests == 0 ) { NSLog(@"done!\n") ; } } @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; UIWebView * webView = [[ UIWebView alloc ] initWithFrame:self.window.bounds ] ; static WebViewDelegate * delegate = nil ; delegate = [[ WebViewDelegate alloc ] init ] ; webView.delegate = delegate ; [self.window addSubview:webView ] ; NSURLRequest * request = [ NSURLRequest requestWithURL:[ NSURL URLWithString:@"http://stackoverflow.com"] ]; [ webView loadRequest:request ] ; return YES; } @end 

(创build一个Xcode示例项目,并用这个replace你的AppDelegate.m)

如果是框架,则表示链接到的页面上的代码中导入的.h文件, 这里是直接下载它们的链接 。 为了获得进一步的帮助,您需要详细说明。

编辑:另外,请参阅: asynchronousWeb服务调用的NSURLConnection NSURLRequest代理

链接的答案解释了如何NSURLRequest请求一个连接,并得到不同的callback,请求的不同状态,如- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data