2013-03-26 24 views
0

我在iOS上使用FusionCharts。我在使用融合圖表加載多個UIWebView時遇到問題。問題是隻有一個webview顯示正確的圖表。第二個加載並呈現圖表,但僅在I 滾動視圖後正確顯示。Multiple Fusioncharts沒有在iOS中顯示

只有在滾動視圖後才能正確呈現圖表。什麼可能導致這種行爲?

謝謝。

+0

是圖表看起來壓在負載 – 2013-03-26 11:44:39

回答

0

這個問題的問題是用UIWebView自己明確解釋下面看看鏈接 http://double-slash.net/2010/10/18/using-multiple-ios-uiwebview-objects/它可以通過採用自旋鎖機制或通過定製UIWebview來增加運行循環的渲染時間來以兩種方式修復。

@interface FCXTCustomWebView() 

@property (assign) id idelegate; 

@end 

@implementation FCXTCustomWebView 

- (id)init 
{ 
self = [super init]; 
if (self) 
{ 
    self.delegate = self; 
} 

return self; 
} 

- (id) initWithCoder:(NSCoder *)aDecoder 
{ 
self = [super initWithCoder:aDecoder]; 
if (self) 
{ 
    self.delegate = self; 
} 

return self; 
} 

- (id)initWithFrame:(CGRect)frame 
{ 
self = [super initWithFrame:frame]; 
if (self) { 
    // Initialization code 
    self.delegate = self; 
} 
return self; 
} 

- (void)setDelegate:(id<UIWebViewDelegate>)delegate 
{ 
_idelegate = delegate; 
} 

- (void)stopRunLoop 
{ 
CFRunLoopRef runLoop = [[NSRunLoop currentRunLoop] getCFRunLoop]; 
CFRunLoopStop(runLoop); 
} 

- (void) webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error 
{ 
[self performSelector:@selector(stopRunLoop) withObject:nil afterDelay:.01]; 

if ([_idelegate respondsToSelector:@selector(webView:didFailLoadWithError:)]) 
{ 
    [_idelegate webView:webView didFailLoadWithError:error]; 
} 
} 

- (BOOL) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType 
{ 
if ([_idelegate respondsToSelector:@selector(webView:shouldStartLoadWithRequest:navigationType:)]) 
{ 
    return [_idelegate webView:webView shouldStartLoadWithRequest:request navigationType:navigationType]; 
} 
else 
{ 
    return YES; 
} 
} 

- (void) webViewDidFinishLoad:(UIWebView *)webView 
{ 
[self performSelector:@selector(stopRunLoop) withObject:nil afterDelay:.01]; 

if ([_idelegate respondsToSelector:@selector(webViewDidFinishLoad:)]) 
{ 
    [_idelegate webViewDidFinishLoad:webView]; 
} 
} 

- (void) webViewDidStartLoad:(UIWebView *)webView 
{ 
[self performSelector:@selector(stopRunLoop) withObject:nil afterDelay:.1]; 
if ([_idelegate respondsToSelector:@selector(stopRunLoop)]) 
{ 
    [_idelegate webViewDidStartLoad:webView]; 
} 
} 

- (void) loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL 
{ 
[super loadHTMLString:string baseURL:baseURL]; 
CFRunLoopRunInMode((CFStringRef)NSDefaultRunLoopMode, 1.5, NO); 
} 

@end