0

我正在从资源文件夹中显示 PDF UIScrollview。但它无法添加。

我补充UIScrollViewViewController。然后采取UIImageView并添加UIScrollView如下代码。

scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0.0, 0.0,768,1024)];
scrollView.contentSize = CGSizeMake(768,2000);
scrollView.delegate = self;
scrollView.pagingEnabled = NO;
[self.view addSubview:scrollView];

UIImageView  *img=[[UIImageView alloc] initWithFrame:CGRectMake(00, 20, 500,900)];
NSString *url = [[NSBundle mainBundle]pathForResource:@"Acknowledgements" ofType:@"pdf"];
img.image=[UIImage imageWithContentsOfFile:url];        
[scrollView addSubview:img]; 

但是滚动视图上没有添加pdf。如果我添加一些图像文件,例如

 NSString *url = [[NSBundle mainBundle]pathForResource:@"trophy" ofType:@"png"];

它被添加。PDF 文件正确并在 Mac 中打开。PPT文件也会发生同样的情况。

出了什么问题。谢谢

4

2 回答 2

0

ppt/pdf 不能添加到 UIImageView 中,而不是添加到 UIWebView 中

NSString *url = [[NSBundle mainBundle]pathForResource:@"Acknowledgements" ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:url];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[webView loadRequest:request];
于 2013-03-26T12:03:27.753 回答
0

@interface UIWebView : UIView < NSCoding, UIScrollViewDelegate > {

UIWebView 实现 UIScrollViewDelegate。因此,您仍然可以处理与滚动相关的事件。检查此链接以获取 UIScrollView http://developer.apple.com/library/ios/#documentation/uikit/reference/uiscrollviewdelegate_protocol/Reference/UIScrollViewDelegate.html的委托方法

于 2013-03-26T12:42:46.090 回答