iOS-打电话、发短信、发邮件、打开浏览器
- (IBAction)showAlert:(UIButton *)sender {
NSString *phoneNumber=@"18500138888";
NSString *url=[NSString stringWithFormat:@"tel://%@",phoneNumber];
[self openUrl:url];
}
- (IBAction)sendMsg:(UIButton *)sender {
NSString *phoneNumber=@"18500138888";
NSString *url=[NSString stringWithFormat:@"sms://%@",phoneNumber];
[self openUrl:url];
}
- (IBAction)sendEmail:(UIButton *)sender {
NSString *mailAddress=@"[email protected]";
NSString *url=[NSString stringWithFormat:@"mailto://%@",mailAddress];
[self openUrl:url];
}
- (IBAction)openBrowser:(UIButton *)sender {
NSString *url=@"http://www.cnblogs.com/kenshincui";
[self openUrl:url];
}
- (void)openUrl:(NSString *)urlStr {
NSURL *url = [NSURL URLWithString:urlStr];
UIApplication *application = [UIApplication sharedApplication];
if (![application canOpenURL:url]) {
NSLog(@"无法打开\"%@\",请确保此应用已经正确安装",url);
return;
}
[[UIApplication sharedApplication] openURL:url];
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。