我需要在视图控制器中使用多个UIWebView
,但在启动应用程序几分钟后,它会因为LoadRequest
.
我在这里找到了这个代码块,UIWebViewDelegate
但我无法成功地将它转换为 C#。
-(void)spinlockedWebViewLoad:(NSArray*)arr {
NSAutoreleasePool* pool=[[NSAutoreleasePool alloc] init];
UIWebView* webView=(UIWebView*)[arr objectAtIndex:0];
NSURLRequest* request=(NSURLRequest*)[arr objectAtIndex:1];
@synchronized(self) {
spinlock=webView;
[webView loadRequest:request];
while (spinlock==webView) [NSThread sleepForTimeInterval:0.1];
}
[pool drain];
}
-(BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
if (spinlock!=webView) {
[NSThread detachNewThreadSelector:@selector(spinlockedWebViewLoad:) toTarget:self withObject:[NSArray arrayWithObjects:webView,request,nil]];
return NO;
}
return YES;
}