0
votes

I'm using FusionCharts on iOS. I'm having problems in loading multiple UIWebView with fusion charts. The problem is that only one webview shows correctly the chart. The second one loads and renders the chart but only shows correctly after I scroll the view.

The charts are rendered properly only after scrolling the view. What could be causing this behaviour?

Thanks.

1
is the charts looks crushed at the loadLochana Ragupathy

1 Answers

0
votes

The problem this issue is is with UIWebView it self for clear explanation check out below link http://double-slash.net/2010/10/18/using-multiple-ios-uiwebview-objects/ It can be fixed in two way by adopting a spin lock mechanism or increasing rendering time of run loop by customize the 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