Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.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
Ios 脱机UIWebView查看旧图像_Ios_Objective C_Image_Caching_Uiwebview - Fatal编程技术网

Ios 脱机UIWebView查看旧图像

Ios 脱机UIWebView查看旧图像,ios,objective-c,image,caching,uiwebview,Ios,Objective C,Image,Caching,Uiwebview,我创建了一个在iOS应用程序中离线运行的UIWebView。我正在利用某个javascript库来显示虚拟游览,这就是为什么我需要使用UIWebView 我现在在运行应用程序时遇到了一个问题:大部分时间它都在显示旧图像,即使它们不在资源中或已更新。我尝试了很多方法来解决这个问题,包括设置缓存策略: NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"splash2" ofType:@"html"

我创建了一个在iOS应用程序中离线运行的
UIWebView
。我正在利用某个javascript库来显示虚拟游览,这就是为什么我需要使用
UIWebView

我现在在运行应用程序时遇到了一个问题:大部分时间它都在显示旧图像,即使它们不在资源中或已更新。我尝试了很多方法来解决这个问题,包括设置缓存策略:

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"splash2" ofType:@"html"]isDirectory:NO];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
[self.webView loadRequest:request];
在我的
viewDidLoad
顶部,我尝试设置缓存容量:

NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
    [NSURLCache setSharedURLCache:sharedCache];
在我的应用程序中,它使用以下选项完成启动:

[[NSURLCache sharedURLCache] removeAllCachedResponses];
目前我的
viewDidLoad中有

NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
    [NSURLCache setSharedURLCache:sharedCache];


    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"splash2" ofType:@"html"]isDirectory:NO];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    [request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
    [self.webView loadRequest:request];

    webView.frame = CGRectMake(0, 0, 1024, 768);

    webView.scalesPageToFit = NO;

    webView.multipleTouchEnabled = YES;

    for (id subview in webView.subviews)
        if ([[subview class] isSubclassOfClass: [UIScrollView class]])
            ((UIScrollView *)subview).bounces = NO;


    [super viewDidLoad];
我还尝试了在我的
viewDidLoad

NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"splash2" ofType:@"html"]isDirectory:NO]];

    webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];


    NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
    [NSURLCache setSharedURLCache:sharedCache];


    [webView loadRequest:request];
    [self.view addSubview:webView];


    webView.scalesPageToFit = NO;

    webView.multipleTouchEnabled = YES;

    for (id subview in webView.subviews)
        if ([[subview class] isSubclassOfClass: [UIScrollView class]])
            ((UIScrollView *)subview).bounces = NO;


    [super viewDidLoad];

我也不确定这是否与html5清单有关。总之,我只想让它关闭缓存,并始终读取我资源中当前存在的内容。

这是一个相当模糊的解释。。。