IOS問題匯總:2014-12-10 在程式中調用Safari和發起撥打電話

來源:互聯網
上載者:User

標籤:

NSURL* url = [[NSURL alloc] initWithString:@“http://blog.csdn.net/iukey”];


[[ UIApplication sharedApplication]openURL:url];

NSURL* url = [[NSURL alloc] initWithString:@“tel:110”];
[[ UIApplication sharedApplication]openURL:url];

ios 調用打電話 三種方式

// 第一種方式打電話
[html] view plaincopy

    • (void)makeACall{
      NSString *number = @“”;// 此處讀入電話號碼
      NSString *num = [[NSString alloc] initWithFormat:@“tel://%@”,number]; //number為號碼字串 如果使用這個方法 結束電話之後會進入連絡人清單
      }
      // 第二種方式打電話 [html] view plaincopy
    • (void)makeACall{
      NSString *num = [[NSString alloc] initWithFormat:@“telprompt://%@”,number]; //而這個方法則打電話前先彈框 是否打電話 然後打完電話之後回到程式中 網上說這個方法可能不合法 無法通過審核
      [[UIApplication sharedApplication] openURL:[NSURL URLWithString:num]]; //撥號
      }
      // 第三種方式打電話 // 下面的代碼能在應用中添加一個電話按鈕,用UIWebView載入電話,這種是合法的,可以上App Store的。 [html] view plaincopy -(void)makeACall{
      NSString *phoneNum = @“”;// 電話號碼
      NSURL *phoneURL = [NSURL URLWithString:[NSString stringWithFormat:@“tel:%@”,phoneNum]];
      if ( !phoneCallWebView ) {
      phoneCallWebView = [[UIWebView alloc] initWithFrame:CGRectZero];// 這個webView只是一個背景View 不需要add到頁面上來 效果跟方法二一樣 但是這個方法是合法的
      }
      [phoneCallWebView loadRequest:[NSURLRequest requestWithURL:phoneURL]];
      }

IOS問題匯總:2014-12-10 在程式中調用Safari和發起撥打電話

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.