如何运行在UIWebView上运行的HTML + javascript文件..?

Sol*_*oft 7 html javascript iphone uiwebview ios

每个人,

我有一个HTML页面,其中包含一个Javascript函数,显示一个动物动画..我已将其本地添加到xcode项目中.

现在当我在UIWebView中加载这个文件时,它看起来很完美.这是将HTMl文件加载到UIWebView的代码

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"elephant-animation" ofType:@"html"] isDirectory:NO];
        NSURLRequest *req = [NSURLRequest requestWithURL:url];
        [self performSelectorOnMainThread:@selector(startWebLoad3:) withObject:req waitUntilDone:YES];

-(void)startWebLoad3:(NSURLRequest *)request
{
    [wbView3 loadRequest:request];
    [wbView3 setBackgroundColor:[UIColor clearColor]];
    wbView3.scrollView.scrollEnabled = NO;
    [wbView3.scrollView setBackgroundColor:[UIColor clearColor]];
    [wbView3 setOpaque:NO];
}
Run Code Online (Sandbox Code Playgroud)

但我有6页.当开始用单独的UIWebView加载每个页面时,它转到内存警告..并给我这样的错误.

void SendDelegateMessage(NSInvocation*): delegate (webView:didFinishLoadForFrame:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode
Run Code Online (Sandbox Code Playgroud)

如果我只运行一个页面而不是它完美运行,但是当我开始一起加载或逐个加载时,它会因内存警告而崩溃.

如果有人得到任何解决方案,请告诉我..

我一直坚持这个问题..

谢谢,

Sol*_*oft 2

终于我找到了解决方案..经过长时间的研发,得到了一些有效的解决方案...

"JavaScript execution time is limited to 10 seconds for each top-level entry point. If your script executes for more than 10 seconds, the web view stops executing the script"
Run Code Online (Sandbox Code Playgroud)

这就是为什么我无法在 UIWebView 中加载 html 页面的原因。iPad 仅在应用程序启动时处理最多 3 MB 的数据加载。而且我已经使用了比它更多的数据。

所以,我根据要求更改了 javascript,现在可以工作了。

感谢您参与其中..