iOS显示PDF

使用UIWebView来显示

iOS显示PDF
//locale file
NSString *html = [NSString stringWithContentsOfFile:path1 encoding:NSUTF8StringEncoding error:nil];
[self.webView loadHTMLString:html baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]bundlePath]]];
//或者
NSString *path = [[NSBundle mainBundle] pathForResource:@"document" ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[webView loadRequest:request];

//remote file
- (void) loadRemotePdf
    {
       CGRect rect = [[UIScreen mainScreen] bounds];
       CGSize screenSize = rect.size;
        
       UIWebView *myWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0,0,screenSize.width,screenSize.height)];
       webView.autoresizesSubviews = YES;
       webView.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);

       NSURL *myUrl = [NSURL URLWithString:@"http://www.mysite.com/test.pdf"];
       NSURLRequest *myRequest = [NSURLRequest requestWithURL:myUrl];
            
       [webView loadRequest:myRequest];

       [window addSubview: myWebView];
       [myWebView release];     
}
iOS显示PDF

iOS显示PDF

上一篇:数据结构----堆 ( Heap )


下一篇:由DataGridTextColumn不能获取到父级DataContext引发的思考