Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在objective-c中快速加载scrollview中的Web视图?_Iphone_Objective C_Ios4_Uiwebview_Uiscrollview - Fatal编程技术网

Iphone 在objective-c中快速加载scrollview中的Web视图?

Iphone 在objective-c中快速加载scrollview中的Web视图?,iphone,objective-c,ios4,uiwebview,uiscrollview,Iphone,Objective C,Ios4,Uiwebview,Uiscrollview,我有20个htmls,我正在webview中加载它。 但是,我在scrollview上创建了3个Web视图,并在html计数完成之前重用这些Web视图。 我正在加载html内容 -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView 滚动网页时,加载速度很慢。我想快速加载这些网页。如何操作。有人能帮我吗。提前谢谢。一个可能的解决方案是在显示之前下载并缓存所有网页 下载HTML网页并在本地编写它们,请参见此答案 创建一个包

我有20个htmls,我正在webview中加载它。 但是,我在scrollview上创建了3个Web视图,并在html计数完成之前重用这些Web视图。 我正在加载html内容

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView 

滚动网页时,加载速度很慢。我想快速加载这些网页。如何操作。有人能帮我吗。提前谢谢。

一个可能的解决方案是在显示之前下载并缓存所有网页

下载HTML网页并在本地编写它们,请参见此答案

创建一个包含这些页面引用的数组,然后将它们加载到
ScrollViewDiEndDeceling
中相应的
UIWebView

更新:

使用上面的链接,它看起来像这样。请注意,我没有测试这个

// NSArray *urls;
// NSMutableArray *filePaths;
- (void)viewDidLoad
{
    [super viewDidLoad];

    urls = [NSArray arrayWithObjects:@"http://www.url1.com", @"http://www.url2.com", @"http://www.url3.com", nil];

    for (int i=0; i<[urls count]; i++)
    {
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *filePath = [NSString stringWithFormat:@"%@/%@.html", [paths objectAtIndex:0], [urls objectAtIndex:i]];   

        NSURL *url = [NSURL URLWithString:[urls objectAtIndex:i]];
        NSData *urlData = [NSData dataWithContentsOfURL:url];
        [urlData writeToFile:filePath atomically:YES];
    }
}

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView 
{
    // Do some calculation to find index of webpage, this depends on
    // the size of the scrollview and the size of the webview.
    int index = ...;

    NSString *filePath = [NSString stringWithFormat:@"%@/%@.html", [paths objectAtIndex:0], [urls objectAtIndex:i]];   
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:filePath]]];      
}
//NSArray*url;
//NSMutableArray*文件路径;
-(无效)viewDidLoad
{
[超级视图下载];
URL=[NSArray arrayWithObjects:@”http://www.url1.com", @"http://www.url2.com", @"http://www.url3.com“,无];

对于(int i=0;i如何创建缓存并执行这些操作。如果有任何示例,请告诉我