icanzilb / MTPopupWindow

Popup-window style view for Objective-C, which loads contents of an HTML file. Easy one-line usage. Check the readme for example
http://www.touch-code-magazine.com/showing-a-popup-window-in-ios6-modernized-tutorial-code-download/
84 stars 26 forks source link

Fix view of content from local files #8

Open felixkirathe opened 10 years ago

felixkirathe commented 10 years ago

in the showInView function add below.

else if ([self.fileName hasPrefix:@"/"]) { //load a local file NSError* error = nil;

    NSString* fileAtPath = self.fileName;

    NSString* fileContents = [NSString stringWithContentsOfFile:fileAtPath encoding:NSUTF8StringEncoding error: &error];

    if (error!=NULL) {
        NSLog(@"error loading %@: %@", self.fileName, [error localizedDescription]);
    } else {
        [self.webView loadHTMLString: fileContents baseURL:[[NSBundle mainBundle] resourceURL]];
    }