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=@"kenshin@hotmail.com";

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];

}

上一篇:aspxgridview export导出数据,把true显示成‘是’


下一篇:RSA加密工具包