「ios入門」 UIWebView でPDFファイルを表示する方法

コード下記:
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
[webView setDelegate:self];
[webView setScalesPageToFit:YES];
[webView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
[webView setAllowsInlineMediaPlayback:YES];
[self.view addSubview:webView];
NSString *pdfPath = [[NSBundle mainBundle] pathForResource:@"ojc" ofType:@"pdf"];
NSURL *url = [NSURL fileURLWithPath:pdfPath];
NSURLRequest *request = [NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:5];
[webView loadRequest:request];

[myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL

URLWithString: @"http://www.arkgame.com/tracy-e/"]]];

NSString *errorString = [NSString stringWithFormat:@"<html><center><font size=

+5 color =’red’>An Error Occurred:<br>%@</fone></center></html>",error];

[myWebView loadHTMLString:errorString baseURL:nil];

//Stopping a load request when the view is to disappear

– (void)viewWillDisappear:(BOOL)animate{

if ([myWebView loading]){

[myWebView stopLoading];

}

myWebView.delegate = nil;

[UIApplication shareApplication].networkActivityIndicatorVisible = NO;

}

IOS

Posted by arkgame