0

I am working on display PDF from resourse folder on UIScrollview. But it is not able to add.

I add UIScrollView on ViewController. Then take a UIImageView and add on UIScrollView as bellow code.

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]; 

But pdf is not added on scrollview. If i add some image file like

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

It get added. PDF file is correct and open in Mac. Same case happen with PPT file.

what is going wrong. Thanks

Bhavin_m
  • 2,746
  • 3
  • 30
  • 49
pallavi_ios
  • 107
  • 1
  • 3
  • 13

2 Answers2

0

ppt/pdf cant be added to UIImageView, rather than add it in UIWebView

NSString *url = [[NSBundle mainBundle]pathForResource:@"Acknowledgements" ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:url];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[webView loadRequest:request];
DivineDesert
  • 6,924
  • 1
  • 29
  • 61
  • thanks .it work on webview.but i want to display on scrollview, so that i can access userinteraction like slide pdf on scrollview,ended reading pdf on scrollview.what replacment for scrollview should i have to use ? – pallavi_ios Mar 26 '13 at 12:10
0

@interface UIWebView : UIView < NSCoding, UIScrollViewDelegate > {

UIWebView implements UIScrollViewDelegate. So you can still handle your scroll related events. Check this link for delegate methods of UIScrollView http://developer.apple.com/library/ios/#documentation/uikit/reference/uiscrollviewdelegate_protocol/Reference/UIScrollViewDelegate.html

Vinoth Kumar
  • 156
  • 8