cha*_*asi 9 xcode uiwebview ios uiwebviewdelegate
我有一个问题的didFinishLoad方法UIWebView是继续射击.我想尝试一下estimatedProgress 解决方案,但不幸的是我不知道在哪里找到这些框架.我正在运行Mountain Lion并使用最新版本的XCode.此外,对于多次触发的UIWebView,这是最好的方法还是有新的方法.似乎有关于SO 的javascript 答案,但这对我不起作用.这可追溯到2009年,我听说苹果公司拒绝任何使用私有API的应用程序.请帮帮我吧!
谢谢大家!
跟踪未完成请求的数量怎么样?我编写了一些似乎有效的测试代码:
@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
Run Code Online (Sandbox Code Playgroud)
(创建一个 Xcode 示例项目并用它替换您的 AppDelegate.m)
| 归档时间: |
|
| 查看次数: |
1406 次 |
| 最近记录: |