2012-07-11 2 views
2

UIWebView가있는 앱을 만들고 있습니다. 링크 : 웹보기 클릭 할 수있는 "내게 전화"링크가되지 않습니다UIWebView가 전화 번호 링크를 감지하지 못합니다.

<a href="tel:123456789">call me</a> 

웹보기는 전화를 포함하는 HTML을로드해야합니다.

나는
webView.dataDetectorTypes = UIDataDetectorTypePhoneNumber 

을 시도했지만 작동하지 않습니다.

나는 모든 stackOverflow Q & A를 보았는데이 문제에 대한 답변이 없습니다. 당신의 도움에 대한

감사합니다, 를 Nur

+1

웹보기

web = [[UIWebView alloc] initWithFrame:WEBVIEW_FRAME]; web.dataDetectorTypes = UIDataDetectorTypeLink | UIDataDetectorTypePhoneNumber; NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"new" ofType:@"html"] isDirectory:NO]]; web.delegate =self; [self.view addSubview:web]; 

및 대리자 방법

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { if ([url.scheme isEqualToString:@"tel"]) { [[UIApplication sharedApplication] openURL:url]; } } 

내 HTML 파일을 추가 나를 위해 일한 u가 작동하고 있다고 설명했던 것처럼 더미 코드 여기 NSString * str = @ "call me"; webview.dataDetectorTypes = UIDataDetectorTypePhoneNumber; [webview loadHTMLString : str baseURL : nil]; – Bhupesh

답변

2

<a href="tel://123456789">call me</a> 

이 당신을 위해 일하는 희망과

<a href="tel:123456789"> call me </a> 

를 교체합니다. 코드 아래

+0

안녕하세요, 작동하지 않았으므로 노력해 주셔서 감사합니다. – nurxyz

+0

그것은 나를 위해 작동합니다. 위임 메소드를 아래와 같이 사용하려면 - (BOOL) webView : (UIWebView *) webView shouldStartLoadWithRequest : (NSURLRequest *) navigationType을 요청하십시오. (UIWebViewNavigationType) navigationType { NSURL * url = request.URL; if ([url.scheme isEqualToString : @ "tel"]) { [[UIApplication sharedApplication] openURL : url]; } return 예; } – sschunara

2

내가 동일 만들었다

<html> 
    <head> 
    <h1>HTML PAGE</h1> 
    </head> 
    <a href="tel:123456789"> call me </a> 
    </html> 
관련 문제