A. 新增一個 View-based Project(ex: viewPDF).
B. 在 Resources 裡, 新增一個 PDF 檔(ex: top.pdf).
C. 在 Interface Builder 的 View 裡, 新增一個 UIWebView.
-----------------------------------------------------------------------------------------------------------------
D. 調整 viewPDFViewController.h 如下:
#import <UIKit/UIKit.h>
@interface viewPDFViewController : UIViewController {
UIWebView *myUIWebView;
}
@property (nonatomic, retain) IBOutlet UIWebView *myUIWebView;
@end
-----------------------------------------------------------------------------------------------------------------
E. 調整 viewPDFViewController.m 如下:
#import "viewPDFViewController.h"
@implementation viewPDFViewController
@synthesize myUIWebView;
........
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
NSString *pdfPath = [[NSBundle mainBundle] pathForResource:@"toc" ofType:@"pdf"];
NSURL *pdfURL = [NSURL fileURLWithPath:pdfPath];
NSURLRequest *pdfRequest = [NSURLRequest requestWithURL:pdfURL];
[myUIWebView loadRequest:pdfRequest];
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
self.myUIWebView = nil;
}
- (void)dealloc {
[myUIWebView release];
[super dealloc];
}
-----------------------------------------------------------------------------------------------------------------
F. 在 Interface Builder , 將 File's Owner 的 Outlets: myUIWebView 連結到 View 下的 UIWebView.
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。