ios打電話、發(fā)短信

如何使用系統(tǒng)自帶的打電話、發(fā)短信、發(fā)郵件、上網(wǎng)?##

使用storyboard畫了下面幾顆按鈕

call.png

點(diǎn)擊相應(yīng)的按鈕執(zhí)行對(duì)應(yīng)的操作

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

打電話###

- (IBAction)callButtonClicked:(UIButton *)sender {
    // 電話號(hào)碼
    NSString *phoneNumber=@"13888888888";
    // 直接撥打電話
    //NSString *url=[NSString stringWithFormat:@"tel://%@",phoneNumber];
    // 會(huì)提示用戶是否撥打電話
    NSString *url=[NSString stringWithFormat:@"telprompt://%@",phoneNumber];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}

發(fā)短信###

- (IBAction)messageButtonClicked:(UIButton *)sender {
    NSString *phoneNumber=@"13888888888";
    NSString *url=[NSString stringWithFormat:@"sms://%@",phoneNumber];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}

發(fā)郵件###

- (IBAction)emailButtonClicked:(UIButton *)sender {
    NSString *mailAddress=@"123456789@qq.com";
    NSString *url=[NSString stringWithFormat:@"mailto://%@",mailAddress];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}

上網(wǎng)###

- (IBAction)internetButtonClicked:(UIButton *)sender {
    NSString *url=@"http://www.baidu.com";
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}

@end

說(shuō)明:按照這種方式進(jìn)行操作,點(diǎn)擊按鈕執(zhí)行完相應(yīng)的操作之后不能回到APP界面了。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容