iOS 打电话、发短信、发邮箱 、跳转网站 功能(系统方法)

//联系人:石虎  QQ: 1224614774昵称:嗡嘛呢叭咪哄

/**

注意:打电话、发短信、发邮箱 、跳转网站 功能(系统方法)---->要真机才有效果

*/

1.简单实现效果图:

iOS 打电话、发短信、发邮箱 、跳转网站 功能(系统方法)


2.实现代码:

@implementation ViewController

//打电话

- (IBAction)makePhone:(id)sender {

    

    NSString *phoneNum = self.phoneTF.text;

    NSString *urlStr = [NSString stringWithFormat:@"tel://%@",phoneNum];

    NSURL *url = [NSURL URLWithString:urlStr];

    // 调用系统内置应用拨打电话

    [[UIApplication sharedApplication] openURL:url];

}

//发信息

- (IBAction)sendMessage:(id)sender {

    

    NSString *urlStr = [NSString stringWithFormat:@"sms://%@",self.phoneTF.text];

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr]];

}

//发邮箱

- (IBAction)sendEmail:(id)sender {

    

    NSString *mailStr = [NSString stringWithFormat:@"mailto://%@",self.emailTF.text];

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:mailStr]];

}

//进入网站

- (IBAction)gotoURL:(id)sender {

    

    NSURL *url = [NSURL URLWithString:self.phoneTF.text];

    [[UIApplication sharedApplication] openURL:url];

}

@end


谢谢!!!