qileilove

          blog已經轉移至github,大家請訪問 http://qaseven.github.io/

          IOS 開發調用打電話,發短信

           1、調用 自帶mail
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://admin@hzlzh.com"]];
            2、調用 電話phone
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8008808888"]];
            iOS應用內撥打電話結束后返回應用
            一般在應用中撥打電話的方式是:
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://123456789"]];
            使用這種方式撥打電話時,當用戶結束通話后,iphone界面會停留在電話界面。
            用如下方式,可以使得用戶結束通話后自動返回到應用:
            UIWebView*callWebview =[[UIWebView alloc] init];
            NSURL *telURL =[NSURL URLWithString:@"tel:10086"];// 貌似tel:// 或者 tel: 都行
            [callWebview loadRequest:[NSURLRequest requestWithURL:telURL]];
            //記得添加到view上
            [self.view addSubview:callWebview];
            還有一種私有方法:(可能不能通過審核)
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt://10086"]];
            3、調用 SMS
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://800888"]];
            4、調用自帶 瀏覽器 safari
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.hzlzh.com"]];
            調用phone可以傳遞號碼,調用SMS 只能設定號碼,不能初始化SMS內容。
            若需要傳遞內容可以做如下操作:
            加入:MessageUI.framework
            #import <MessageUI/MFMessageComposeViewController.h>
            實現代理:MFMessageComposeViewControllerDelegate
            調用sendSMS函數
          //內容,收件人列表
          - (void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSArray *)recipients
          {
          MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];
          if([MFMessageComposeViewController canSendText])
          {
          controller.body = bodyOfMessage;
          controller.recipients = recipients;
          controller.messageComposeDelegate = self;
          [self presentModalViewController:controller animated:YES];
          }
          }
          // 處理發送完的響應結果
          - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
          {
          [self dismissModalViewControllerAnimated:YES];
          if (result == MessageComposeResultCancelled)
          NSLog(@"Message cancelled")
          else if (result == MessageComposeResultSent)
          NSLog(@"Message sent")
          else
          NSLog(@"Message failed")
          }
            默認發送短信的界面為英文的,解決辦法為:
            在.xib 中的Localization添加一組chinese就ok了

          posted on 2014-08-04 09:58 順其自然EVO 閱讀(1336) 評論(0)  編輯  收藏 所屬分類: 測試學習專欄

          <2014年8月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          導航

          統計

          常用鏈接

          留言簿(55)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 若尔盖县| 商丘市| 雷州市| 墨江| 静海县| 宜宾市| 仪征市| 新晃| 五莲县| 南川市| 武隆县| 浮梁县| 龙山县| 岑溪市| 绵竹市| 綦江县| 夏邑县| 浠水县| 东山县| 抚顺县| 延庆县| 文山县| 洛阳市| 永年县| 威宁| 新丰县| 永济市| 平果县| 嘉义县| 通许县| 大同县| 徐闻县| 介休市| 南昌市| 昭觉县| 深州市| 萝北县| 都江堰市| 海门市| 湘潭市| 团风县|