Co o utrzymanie śledzenie liczby zaległych wniosków? I bitą trochę kodu testu, który wydaje się działać:
@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
(Utwórz przykładowy projekt Xcode i zastąpić AppDelegate.m z tym)
fajne rozwiązanie ! dość ciekawe! –
tak, ładnie. to działa dla mnie. –