UIWebView的使用这里不多说了,可参见http://blog.csdn.net/iunion/article/details/7963291
主要使用了RegexKitLite正则类库分析替换数据
链接操作使用:
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType { NSLog(@"shouldStartLoadWithRequest"); BOOL result = YES; NSURL *requestURL = [request URL]; NSString *requestString = [[request URL] absoluteString]; NSLog(@"URL: %@", requestString); NSString *schemeStr = [requestURL scheme]; if ( ([schemeStr isEqualToString:@"http"] || [schemeStr isEqualToString:@"https"] || [schemeStr isEqualToString:@"mailto"] || [schemeStr isEqualToString:@"tel"]) && (navigationType == UIWebViewNavigationTypeLinkClicked) ) { result = ![[UIApplication sharedApplication] openURL:requestURL]; } else if ([schemeStr isEqualToString:@"wixun"]) { NSString *host = [requestURL host]; if ([host isEqualToString:@"user"]) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[[requestURL queryArgumentForKey:@"username"] URLDecodedString] message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; return NO; } } return result; }
例子下载