Solution iOS phone prompt box response slow

Source: Internet
Author: User

Add a class method, and then call directly

+ (void) Callphonestr: (nsstring*) phonestr WITHVC: (Uiviewcontroller *) selfvc{if (Phonestr.length >=) {NSString *
STR2 = [[Uidevice currentdevice] systemversion]; if ([str2 compare:@ "10.2" options:nsnumericsearch] = = Nsordereddescending | | [Str2 compare:@ "10.2" options:nsnumericsearch] = = nsorderedsame) {nsstring* phonestr = [NSString stringwithformat:@]
telprompt://%@ ", Phonestr]; [[UIApplication sharedapplication] Openurl:[nsurl urlwithstring:phonestr] options:@{} completionHandler:^ (BOOL

Success) {NSLog (@ "phone success");  }else {nsmutablestring* str1 = [[nsmutablestring alloc]initwithstring:phonestr];//exists heap area, variable string if (Phonestr.length = 10) {[Str1 insertstring:@ "-" atindex:3];//inserts a string into one of the other strings [str1 insertstring:@ "-" atindex:7];// Inserts a string into one of the other strings}else {[str1 insertstring:@ "-" atindex:3];//inserts a string into one of the other strings [str1 insertstring:@ "-"
atindex:8];//inserts a string into one of the other strings} NSString * str = [NSString stringwithformat:@ "Call \n%@", str1]; Uialertcontroller *alert= [Uialertcontroller alertcontrollerwithtitle:str message:nil Preferredstyle:uialertcontrollerstylealert];
Set PopOver to point to item alert.popoverPresentationController.barButtonItem = Selfvc.navigationItem.leftBarButtonItem; Add button [Alert addaction:[uialertaction actionwithtitle:@ ' call ' style:uialertactionstyledestructive handler:^ (
Uialertaction *action) {NSLog (@ "Click on Call Button 10.2");
nsstring* phonestr = [NSString stringwithformat:@ "tel://%@", phonestr]; if ([Phonestr hasprefix:@ "SMS:"] | | [Phonestr hasprefix:@ "Tel:"]) {uiapplication * app = [uiapplication sharedapplication]; if ([App Canopenurl:[nsurl Urlwithstring:phonestr]]) {app Ope
Nurl:[nsurl Urlwithstring:phonestr]];
}
}
}]]; [Alert addaction:[uialertaction actionwithtitle:@ "Cancel" Style:uialertactionstylecancel handler:^ (UIAlertAction *
Action) {NSLog (@ "clicked Cancel button");}];
[SELFVC Presentviewcontroller:alert Animated:yes Completion:nil]; }
}
}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.