본문 바로가기

Programming/iOS

화면에 PDF 띄우기

반응형
UIWebView를 통해서 화면에 PDF를 띄우는 소스

소스코드

PDFTestController.h
@interface PDFTestController : UIViewController<UIWebViewDelegate> {
    UIWebView *pdfWebView;
}

PDFTestController.m
    pdfWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
    pdfWebView.backgroundColor = [UIColor whiteColor];
    pdfWebView.scalesPageToFit = YES;
    pdfWebView.contentMode = UIViewContentModeScaleAspectFill;
    pdfWebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
    pdfWebView.delegate = self;
    [self.view addSubview:pdfWebView];
   
    NSURL *pdfURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"test.pdf" ofType:nil]];
    [pdfWebView loadRequest:[NSURLRequest requestWithURL:pdfURL]];



반응형

'Programming > iOS' 카테고리의 다른 글

timezone 설정하기  (0) 2011.04.22
CATransition 이용(화면전환 에니메이션)  (0) 2011.04.12
Objective-C의 튜토리얼 번역  (0) 2011.04.06
NSString 문자열 자르기  (0) 2011.04.05
iOS SDK 버전  (0) 2011.03.30