Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added initWithHTMLString to load HTML's string
Can be reload and go back from next web, because save a temp html file
in to tmp dir.
  • Loading branch information
FrankWu100 committed Nov 28, 2013
commit b63c8e0881a829b4f00c6efb6e62faab46e90d34
1 change: 1 addition & 0 deletions SVWebViewController/SVWebViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@

- (id)initWithAddress:(NSString*)urlString;
- (id)initWithURL:(NSURL*)URL;
- (id)initWithHTMLString:(NSString*)HTMLString;

@end
14 changes: 14 additions & 0 deletions SVWebViewController/SVWebViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ @interface SVWebViewController () <UIWebViewDelegate>

- (id)initWithAddress:(NSString*)urlString;
- (id)initWithURL:(NSURL*)URL;
- (id)initWithHTMLString:(NSString*)HTMLString;
- (void)loadURL:(NSURL*)URL;

- (void)updateToolbarItems;
Expand Down Expand Up @@ -59,6 +60,19 @@ - (id)initWithURL:(NSURL*)pageURL {
return self;
}

- (id)initWithHTMLString:(NSString*)pageHTMLString {

if(self = [super init]) {
NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES];
NSURL *fileURL = [[tmpDirURL URLByAppendingPathComponent:@"SVWebTemp"] URLByAppendingPathExtension:@"html"];

[pageHTMLString writeToFile:[fileURL path] atomically:YES encoding:NSUTF8StringEncoding error:nil];
self.URL = fileURL;
}

return self;
}

- (void)loadURL:(NSURL *)pageURL {
[self.webView loadRequest:[NSURLRequest requestWithURL:pageURL]];
}
Expand Down