IOS:如何在UIWebview中逐页显示文档

时间:2013-12-26 05:13:42

标签: ios iphone ios6 uiwebview

我需要显示Pdf& Doc文件格式逐页。我选择UIWebview来显示文档。但我无法逐页显示或将页面与其他页面区分开来。

这是我的代码:

//-- Getting file path from document directory
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *fileLocation = [NSString stringWithFormat:@"%@/sample.doc",documentsDirectory];

//--UIWebview initialization
UIWebView *myWebView=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
myWebView.scalesPageToFit = YES;
myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:fileLocation]]];
NSLog(@"%@",[NSURL fileURLWithPath:fileLocation]); // I 
[self.view addSubview:myWebView];

任何人都可以帮助如何逐页显示。

1 个答案:

答案 0 :(得分:2)