0
votes

Can someone tell me why am getting this error and how to resolve this error . Am trying to load a html file which is saved locally under a folder inside the documents directory . The html file has jss and css files linked to it . Please help me resolve this issue .

  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
        NSString *path = [paths  objectAtIndex:0];

        NSLog(@"Saving");

        NSUserDefaults *prefs = [[NSUserDefaults alloc] init];

        bookid = [NSString stringWithFormat:@"%@",[prefs objectForKey:@"bookid"]];

        NSString *path1 = [NSString stringWithFormat:@"/%@",bookid];

        NSString *dataPath = [path stringByAppendingPathComponent:path1];

        dataPath = [dataPath stringByStandardizingPath];

        NSArray *directoryContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:dataPath error:NULL];

        for (int count = 0; count < (int)[directoryContent count]; count++)
        {

                NSLog(@"File %d: %@", (count + 1), [directoryContent objectAtIndex:count]);

        }

        filePath = [dataPath stringByAppendingPathComponent:@"index.html"];

        NSString* htmlString = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
        [_BookReaderWeb loadHTMLString:htmlString
                        baseURL:[NSURL fileURLWithPath:dataPath]];

This is the error which am getting :

Error Domain=NSURLErrorDomain Code=-1100 "The requested URL was not found on this server." UserInfo=0x7ffb2a96acf0 {NSUnderlyingError=0x7ffb286b7d20 "The requested URL was not found on this server.", NSErrorFailingURLStringKey=file:///Users/ChanqBro/Library/Developer/CoreSimulator/Devices/A54D2148-91C3-49F4-B94C-CE46DEAEEC58/data/Containers/Data/Application/D08784A9-D5DD-41DE-95C5-DB97BE91BBBC/Library/Caches/3021/blank.html, NSErrorFailingURLKey=file:///Users/ChanqBro/Library/Developer/CoreSimulator/Devices/A54D2148-91C3-49F4-B94C-CE46DEAEEC58/data/Containers/Data/Application/D08784A9-D5DD-41DE-95C5-DB97BE91BBBC/Library/Caches/3021/blank.html, NSLocalizedDescription=The requested URL was not found on this server.}

<html>
<head>
<meta charset="UTF-8">
<title> HELLO </title>

<!-- MONOCLE CORE -->
<script type="text/javascript" src="monocore.js"></script>
<script type="text/javascript" src="monoctrl.js"></script>  
<script type="text/javascript" src="book_data.js"></script>
<script type="text/javascript" src="test.js"></script>


<link rel="stylesheet" type="text/css" href="monocore.css" />
<link rel="stylesheet" type="text/css" href="monoctrl.css" />
<link rel="stylesheet" type="text/css" href="test.css" />

</head>
<body>
<div id="reader"></div>
</body>
</html>
1
Guys any help ?? Am badly stuck with this problem !! :( - Nikilicious
Is there are file named blank.html in that directory? - Jeffery Thomas
No jeffery there is no file named blank.html . The html opens up in safari and mozila but not in Chrome as this has iframe . - Nikilicious
Why is index.html requesting blank.html? Somewhere in the HTML, CSS or JavaScript, the URL is being asked for. - Jeffery Thomas
I will edit my question with the html file . Please check that . - Nikilicious

1 Answers

0
votes

After a quick check, I see that you are using Monocle. Doing a search of monocle and blank.html, I found a couple of issues with Monocle on iOS that were fixed by adding an HTML file to a blank page called blank.html.

see https://github.com/joseph/Monocle/issues/51 or https://github.com/joseph/Monocle/issues/99

So now adding blank.html to your root dir should solve it. (I don't use UIWebView myself, so I'm proceeding on your advice here!)