사용자 정의 이미지, 링크, 웨 이 보 에서 '@' 과 '\ #' 과 같은 특수 한 전의 문 자 를 분석 하고 UIWebView 에 표시 하 는 예

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;
}

예 다운로드

좋은 웹페이지 즐겨찾기