didFinishLoad
中的UIWebView
方法存在问题。我想尝试一下estimatedProgress solution,但不幸的是我不知道在哪里找到这些框架。我正在运行Mountain Lion并使用最新版本的XCode。此外,对于多次触发的UIWebView,这是最好的方法还是有新的方法。在SO上似乎有一个javascript answer,但这对我不起作用。这可追溯到2009年,我听说苹果公司拒绝任何使用私有API的应用程序。请帮帮我吧!
谢谢大家!
答案 0 :(得分:2)
如何跟踪未完成的请求数量?我掀起了一些似乎有效的测试代码:
@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
(创建一个Xcode示例项目并用此替换您的AppDelegate.m)
答案 1 :(得分:0)
如果框架是指您链接到的页面上的代码中导入的.h文件,here's the link可直接下载它们。如需进一步的帮助,您需要详细说明。
编辑:此外,请参阅:NSURLConnection NSURLRequest proxy for asynchronous web service calls
链接的答案解释了如何NSURLRequest
请求连接并针对请求的不同状态获取不同的回调,例如- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data