iOS 调用 系统相机 相册

ios打电话、发短信

2016-01-20  本文已影响298人  pingui

如何使用系统自带的打电话、发短信、发邮件、上网?##

使用storyboard画了下面几颗按钮

call.png

点击相应的按钮执行对应的操作

@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 {
    // 电话号码
    NSString *phoneNumber=@"13888888888";
    // 直接拨打电话
    //NSString *url=[NSString stringWithFormat:@"tel://%@",phoneNumber];
    // 会提示用户是否拨打电话
    NSString *url=[NSString stringWithFormat:@"telprompt://%@",phoneNumber];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}

发短信###

- (IBAction)messageButtonClicked:(UIButton *)sender {
    NSString *phoneNumber=@"13888888888";
    NSString *url=[NSString stringWithFormat:@"sms://%@",phoneNumber];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}

发邮件###

- (IBAction)emailButtonClicked:(UIButton *)sender {
    NSString *mailAddress=@"123456789@qq.com";
    NSString *url=[NSString stringWithFormat:@"mailto://%@",mailAddress];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}

上网###

- (IBAction)internetButtonClicked:(UIButton *)sender {
    NSString *url=@"http://www.baidu.com";
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}

@end

说明:按照这种方式进行操作,点击按钮执行完相应的操作之后不能回到APP界面了。

上一篇下一篇

猜你喜欢

热点阅读