添加要显示的文件(通常在ViewDidLoad方法中)
//添加要显示的文件 NSString *filePath = [[NSBundle mainBundle]pathForResource:@"HitBean" ofType:@"htm"]; NSData *aboutData = [NSData dataWithContentsOfFile:filePath]; if (aboutData) { aboutView.opaque = NO; aboutView.backgroundColor = [UIColor clearColor]; [aboutView loadData:aboutData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:nil]; }
点击web页面中的链接
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType { if (navigationType == UIWebViewNavigationTypeLinkClicked)//点击链接 { NSURL *URL = [request URL]; if ([[URL scheme] isEqualToString:@"aaa"]) { NSString *tempStr=[[URL absoluteString] substringFromIndex:4]; if([tempStr isEqualToString:@"bbb"]==YES) { [self addToFavourite]; } if ([tempStr length] == 38) { BOOL voiceFlag = [[SQL sharedSql] saveAudio:tempStr]; if (voiceFlag) { [[AVCommon sharedAVCommon] playAudio:tempStr]; } else { } } } } return YES; }
打开其他的web网页
- (IBAction)goChris { NSLog(@"Go Chris"); NSURLRequest *URLRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://tieba.baidu.com/f?kw=