Implementation of dialing calls in iOS

Source: Internet
Author: User

Define actions When you click the Dial button
    1. -(void) callaction{
    2. NSString *number = @""; Read the phone number in here
    3. NSString *num = [[NSString alloc]initwithformat:@ "tel://%@", number]; Number is a string if you end the call using this method, the contact list is entered
    4. NSString *num = [[NSString alloc]initwithformat:@"telprompt://%@", number];//And this method is used to call the box before calling and then return to the program after the call. The internet says the method may not be legal and cannot be audited.
    5. [[UIApplication sharedapplication] openurl:[nsurlurlwithstring:num]; //Dialing
    6. }


The following code can add a phone button to the app and tap to call the phone number. It's also useful for iPhone developers. Add Phone icon button
    1. UIButton *btnphone = [[Uibuttonbuttonwithtype:uibuttontyperoundedrect]retain];
    2. Btnphone.frame =cgrectmake (280,10,30,30);
    3. [Btnphone Setbackgroundcolor:[uicolor Redcolor];
    4. Tap the Dial button to dial directly
    5. [Btnphone addtarget:self Action: @selector (Callaction) forcontrolevents:uicontroleventtouchupinside];
    6. [Self.window Addsubview:btnphone];


The third way to hit the electricity
    1. -(void) callphone{
    2. NSString *phonenum = @""; Phone number
    3. Nsurl *phoneurl = [Nsurl urlwithstring:[nsstringstringwithformat:@"tel:%@", Phonenum]];
    4. if (!phonecallwebview) {
    5. Phonecallwebview = [[UIWebView Alloc]initwithframe:cgrectzero]; //This webview is just a backstage easy don't need add to page effect with method two but this method is legal
    6. }
    7. [Phonecallwebview Loadrequest:[nsurlrequestrequestwithurl:phoneurl]];
    8. }

 

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.