qileilove

          blog已經(jīng)轉(zhuǎn)移至github,大家請訪問 http://qaseven.github.io/

          IOS 開發(fā)調(diào)用打電話,發(fā)短信

           1、調(diào)用 自帶mail
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://admin@hzlzh.com"]];
            2、調(diào)用 電話phone
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8008808888"]];
            iOS應(yīng)用內(nèi)撥打電話結(jié)束后返回應(yīng)用
            一般在應(yīng)用中撥打電話的方式是:
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://123456789"]];
            使用這種方式撥打電話時,當(dāng)用戶結(jié)束通話后,iphone界面會停留在電話界面。
            用如下方式,可以使得用戶結(jié)束通話后自動返回到應(yīng)用:
            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、調(diào)用 SMS
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://800888"]];
            4、調(diào)用自帶 瀏覽器 safari
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.hzlzh.com"]];
            調(diào)用phone可以傳遞號碼,調(diào)用SMS 只能設(shè)定號碼,不能初始化SMS內(nèi)容。
            若需要傳遞內(nèi)容可以做如下操作:
            加入:MessageUI.framework
            #import <MessageUI/MFMessageComposeViewController.h>
            實現(xiàn)代理:MFMessageComposeViewControllerDelegate
            調(diào)用sendSMS函數(shù)
          //內(nèi)容,收件人列表
          - (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];
          }
          }
          // 處理發(fā)送完的響應(yīng)結(jié)果
          - (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")
          }
            默認(rèn)發(fā)送短信的界面為英文的,解決辦法為:
            在.xib 中的Localization添加一組chinese就ok了

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

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

          導(dǎo)航

          統(tǒng)計

          常用鏈接

          留言簿(55)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 即墨市| 万载县| 沈阳市| 策勒县| 贵阳市| 乐东| 堆龙德庆县| 广昌县| 马尔康县| 双城市| 南部县| 武平县| 哈巴河县| 仪征市| 凯里市| 江城| 南汇区| 延边| 遵化市| 华安县| 内黄县| 廉江市| 伊春市| 临海市| 吉林省| 徐闻县| 无极县| 汉沽区| 惠水县| 响水县| 剑川县| 陈巴尔虎旗| 临夏县| 汨罗市| 右玉县| 安陆市| 景东| 岳池县| 新泰市| 永寿县| 象山县|