【发布时间】:2013-09-10 07:48:54
【问题描述】:
我是 ios 开发新手。我正在尝试在 UIWebview 中心显示 pdf。我在 mainbundle 中有一个 pdf。这是我的 PDF 现在加载到 UIWebView 时的样子:(我放入了棕色渐变作为 UIWebView 的背景,因此您可以更好地了解我的意思)。
- (void)viewDidLoad
{
UIWebView *theWebView = [[UIWebView alloc] initWithFrame:[self.view bounds]];
[theWebView setContentMode:UIViewContentModeScaleAspectFit];
[theWebView setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth];
[theWebView setScalesPageToFit:YES];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"pdf"];
NSURL *filePathURL = [NSURL fileURLWithPath:filePath];
[theWebView loadRequest:[NSURLRequest requestWithURL:filePathURL]];
[self.view addSubview:theWebView];
[super viewDidLoad];
}
我想将其居中,以使下边距与上边距相同。我将如何使用 PDF(本地)执行此操作?
【问题讨论】:
-
UIWebView 不适合那样使用。寻找 pdf 查看器/解析器,类似于 github.com/vfr/Reader
-
@NimrodGutman 是否可以在 html 代码的帮助下加载 pdf 文件 uiwebview center 使用
-
已经在某处看到过截图……你已经问过同样的问题了吗?
-
@iOSCoder yes but not same.previously 问如何加载pdf文件uiwebview全屏
-
@Ravindhiran...如何拥有 (1) 一个灰色背景的 view1 (2) 然后在 view1 的中心添加 webview?
标签: iphone ios objective-c pdf uiwebview