Search code examples
ioswebviewwebservermampdoc

unable to display .doc from server


I'm trying to load documents into my app for display and this works if they're stored locally but not from the server. I'm testing with MAMP. Here's my viewDidLoad method:

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSURL *myUrl = [NSURL URLWithString:@"http://localhost:8888/FilesForApp/Docs/MS.doc"];
    NSURLRequest *myRequest = [NSURLRequest requestWithURL:myUrl];
    [_webView loadRequest:myRequest];
}

Can anyone point tell me if there's something missing from this?

-EDIT- Forgot to add, it doesn't crash, just shows a plain, white display.


Solution

    1. Make sure you can access that doc through your web browser(make sure the doc exists).
    2. Try to add the http:// prefix.
    3. Don't forget to add _webView as subView to your view.
    4. Don't forget to set the _webView's frame.