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

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

         QQ群:807236138  群称:iOS 技术交流学习群

/**

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

*/

1.简单实现效果图:

2.实现代码:

@implementationViewController

//打电话

- (IBAction)makePhone:(id)sender {

NSString*phoneNum =self.phoneTF.text;

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

NSURL*url = [NSURLURLWithString:urlStr];

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

[[UIApplicationsharedApplication]openURL:url];

}

//发信息

- (IBAction)sendMessage:(id)sender {

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

[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:urlStr]];

}

//发邮箱

- (IBAction)sendEmail:(id)sender {

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

[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:mailStr]];

}

//进入网站

- (IBAction)gotoURL:(id)sender {

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

[[UIApplicationsharedApplication]openURL:url];

}

@end

谢谢!!!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容