iOS 가 전 화 를 거 는 3 가지 실현 방식

1420 단어 ios걸다전화.
iOS 에서 전 화 를 걸 수 있 는 방법:
방법 1.request WithURL,이 방법 은 전 화 를 걸 기 전에 알림 을 팝 업 합 니 다.

NSMutableString * string = [[NSMutableString alloc] initWithFormat:@"tel:%@",@"136****0000"];
UIWebView * callWebview = [[UIWebView alloc] init];
[callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:string]]];
[self.view addSubview:callWebview];
swift 코드:

let callWebview = UIWebView()callWebview.loadRequest(NSURLRequest(url: URL(string: "tel:136****0000")!) as URLRequest)
self.view.addSubview(callWebview)
방법 2.openURL(telprompt),이 방법 으로 전 화 를 걸 기 전에 알림 이 뜨 면 App Store 심사 에 통과 하지 못 할 수 있 습 니 다.

NSMutableString * string = [[NSMutableString alloc] initWithFormat:@"telprompt:%@",@"136****0000"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:string]];
swift 코드:
방법 3.openURL(tel)을 이용 하여 iOS 10.2 이전에 탄 상 자 를 추가 하지 않 고 스스로 처리 해 야 하 며 수 동 으로 alert 를 추가 하면 됩 니 다.

NSMutableString * string = [[NSMutableString alloc] initWithFormat:@"tel:%@",@"136****0000"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:string]];
총결산
위 에서 말 한 것 은 편집장 이 소개 한 iOS 가 전 화 를 걸 수 있 는 3 가지 실현 방식 입 니 다.여러분 에 게 도움 이 되 기 를 바 랍 니 다.궁금 한 점 이 있 으 시 면 저 에 게 메 시 지 를 남 겨 주세요.편집장 은 바로 답 해 드 리 겠 습 니 다!

좋은 웹페이지 즐겨찾기