2013-07-03 9 views
6

में लोड किया गया है, मैंने संसाधन बंडल से UIWebView में एक पीडीएफ फ़ाइल लोड की है।पीडीएफ को ज़ूम/पिन करें जो UIWebView

अब, मैं पीडीएफ फ़ाइल ज़ूम/चुटकी करने में सक्षम नहीं हूं।

मैं नीचे 2 प्रासंगिक लिंक मिल गया, लेकिन जवाब में से कोई भी सही रूप में चिह्नित कर रहे हैं -

  1. How to zoom webView with pdf file

  2. Enable zooming/pinch on UIWebView

पीडीएफ zoomable बनाने के लिए/चुटकी जो संसाधन बंडल से UIWebView में लोड किया गया है, क्या नीचे समाधान समाधान होगा?

  1. Problem with pdf while opening in UIWebView

आपकी मदद के लिए धन्यवाद।

+0

क्या आपने कोई समाधान पाया है? – Amar

+0

पीडीएफ फाइलों को दिखाने के लिए त्वरित देखो ढांचे का उपयोग क्यों नहीं कर रहे हैं? –

+0

केवल ** yourwebView.scalesPageToFit = YES; ** वेब में ज़ूमिंग सक्षम करें कुछ भी नहीं - अन्य अतिरिक्त कोड की आवश्यकता है बस वेबवीवे और स्केल में पीडीएफ लोड करेंPageToFit yes –

उत्तर

7

पर इंटरफ़ेस बिल्डर ऐड जांच को स्केल पृष्ठ अपने WebView फिट करने के लिए और आप एक पिंच zoomin Zoomout सक्षम;)

या अपने पीडीएफ इस कोड को देखो करने के लिए प्रयास करता है, तो आप बेहतर बालक हैं:

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    [webView loadRequest:[NSURLRequest requestWithURL:@"http:pdfURL"]]; 

    NSString *path = [[NSBundle mainBundle] pathForResource:@"yourPDFFile" ofType:@"pdf"]; 
    NSURL *url = [NSURL fileURLWithPath:path]; 
    NSURLRequest * request = [NSURLRequest requestWithURL:url]; 
    [webView loadRequest:request]; 
    //--------------AND HERE USE SCALE PAGE TO FIT------------------// 
    [webView setScalesPageToFit:YES]; 

} 

UIWebView आशा है कि यह आपकी मदद करेगा।

3

// इस

NSString *[email protected]"www.example.com/yy.pdf"; 
web=nil; 
web=[[UIWebView alloc] initWithFrame:CGRectMake(0, 98, 320, 367)]; 
web.delegate=self; 
[self.view addSubview:web]; 
[web loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlstr]]]; 
UIPinchGestureRecognizer *pgr = [[UIPinchGestureRecognizer alloc] 
           initWithTarget:self action:@selector(handlePinch:)]; 
pgr.delegate = self; 
[web addGestureRecognizer:pgr]; 

// लक्ष्य कार्रवाई

- (IBAction)handlePinch:(UIPinchGestureRecognizer *)recognizer 
{ 
    recognizer.view.transform = CGAffineTransformScale(recognizer.view.transform, recognizer.scale, recognizer.scale); 
recognizer.scale = 1; 
    } 

इस से पहले की तरह की कोशिश करो ज में UIGestureRecognizerDelegate जोड़ें। उम्मीद है कि यह आपकी मदद करेगा ..

1
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES); 

NSString *documentsDirectory = [paths objectAtIndex:0]; 

NSFileManager *fileManager = [NSFileManager defaultManager]; 

if ([fileManager fileExistsAtPath:documentsDirectory]) 
{ 
    NSURL *url = [NSURL fileURLWithPath:strFileName]; 
    NSURLRequest *request = [NSURLRequest requestWithURL:url]; 
    [webView setScalesPageToFit:YES]; 
    [webview loadRequest:request]; 
}