如何使用系統(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界面了。