iphone - Can’t Display A Microsoft Word.doc document on UIView Controller -
i’m using code below display pdfs or filename.doc microsoft word documents. works fine when use oftype:@:”pdf”, code crashes when use oftype:@:”doc” or oftype:@:”docx”. word document text , few url links. appreciated.
nsstring *path = [[nsbundle mainbundle] pathforresource:@"c9" oftype:@"doc"]; pdfurl = [nsurl fileurlwithpath:path];} [webview loadrequest:[nsurlrequest requestwithurl:pdfurl]];
as per code, looks you're using uiwebview
.
here code i've used in past.
-(void)loaddocument:(nsstring*)documentname inview:(uiwebview*)webview { nsstring *path = [[nsbundle mainbundle] pathforresource:documentname oftype:nil]; nsurl *url = [nsurl fileurlwithpath:path]; nsurlrequest *request = [nsurlrequest requestwithurl:url]; [webview loadrequest:request]; }
in viewdidload (change webview frame whatever need)..
uiwebview *webview = [[uiwebview alloc] initwithframe:cgrectmake(10, 10, 200, 200)]; [self.view addsubview:webview]; [self loaddocument:@"file.doc" inview:webview];
Comments
Post a Comment