ios之实现打电话,发邮件《iPhone自身有问题》,发短信,浏览网页,启动另一份应用

原文链接:http://www.cnblogs.com/kenshincui/p/4220402.html#systemApplication

 

 

- (IBAction)callClick:(id)sender {

    NSString *phoneNum = @"12345678901";

//    NSString *url = [NSString stringWithFormat:@"tel://%@",phoneNum]; //这种会直接打

    NSString *url = [NSString stringWithFormat:@"telprompt://%@",phoneNum];//会有提示

    [self openURL:url];

}

- (IBAction)sendMessage:(id)sender {

    NSString *phoneNum = @"15337278823332";

    NSString *url = [NSString stringWithFormat:@"sms://%@",phoneNum];

    [self openURL:url];

}

- (IBAction)sendEmail:(id)sender {

    NSString *mailAdd = @"1264129401@qq.com";

    NSString *url = [NSString stringWithFormat:@"mailto://%@",mailAdd];

    [self openURL:url];

}

- (IBAction)browserClick:(id)sender {

    NSString *str = @"http://www.baidu.com";

    [self openURL:str];

}

- (IBAction)ThirdApp:(id)sender {

//需要设置另一份应用的urlSchemes

 

 

    NSString *str = @"menu:";

    [self openURL:str];

}

 

#pragma mark - 私有方法

- (void)openURL:(NSString *)url{

    

    NSURL *URL = [NSURL URLWithString:url];

    UIApplication *app = [UIApplication sharedApplication];

    /**

     *  把if注释掉,实际上可以打开,主要是在应用A启动应用B的时候会出问题

     */

    if (![app canOpenURL:URL]) {

        NSLog(@"无法打开应用");

        return;

    }

    [[UIApplication sharedApplication]openURL:URL];

    

    

}

 

posted @ 2016-05-20 11:20  芥末sweet  阅读(119)  评论(0编辑  收藏  举报