【问题标题】:Multiple Fusioncharts is not getting displayed in iOS多个 Fusioncharts 未在 iOS 中显示
【发布时间】:2013-03-16 04:31:59
【问题描述】:

我在 iOS 上使用 FusionCharts。我在使用融合图表加载多个 UIWebView 时遇到问题。问题是只有一个 webview 正确显示了图表。第二个加载并呈现图表,但仅在我滚动视图后正确显示。

仅在滚动视图后才能正确呈现图表。什么可能导致这种行为?

谢谢。

【问题讨论】:

  • 图表在负载下看起来是否破碎

标签: ios uiwebview fusioncharts


【解决方案1】:

这个问题的问题在于 UIWebView 它自己为了清楚的解释查看下面的链接 http://double-slash.net/2010/10/18/using-multiple-ios-uiwebview-objects/ 可以通过自旋锁机制或者自定义UIWebview增加run loop的渲染时间两种方式修复。

@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

【讨论】:

    猜你喜欢
    • 2021-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-05
    • 1970-01-01
    • 2023-04-03
    相关资源
    最近更新 更多