zoukankan      html  css  js  c++  java
  • Iphone UIApplication openURL能帮助你运行Maps,SMS,Browser, Calling甚至其他的应用程序

    openURL能帮助你运行Maps,SMS,Browser,Phone甚至其他的应用程序。这是Iphone开发中我经常需要用到的一段代码,它仅仅只有一行而已。
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8004664411"]];
    这个程序通过基础的协议支持拨打电话的功能
    译者附:
    -(IBAction)openMaps {//打开地图
    // Where is Apple on the map anyway?


    NSString* addressText = @”1 Infinite Loop, Cupertino, CA 95014″;
    addressText = [addressText stringByAddingPercentEscapesUsingEncoding: NSASCIIStringEncoding];
    NSString* urlText = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@", addressText];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];


    }

    //打开地图直接搜索中文位置需要特殊编码,例子如下:


    - (IBAction)gotoHospitalMapAction: (id)sednder
    {

        NSLog(@"gotoHospitalMapAction");
        NSString *strHospitalAddress = @"南京市水西门大街文体西路9号";
        NSString *strHospitalMap = @"http://maps.google.com/maps?q=";
        NSURL *searchMap = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@", strHospitalMap,
        [strHospitalAddress stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
        [[UIApplication sharedApplication] openURL:searchMap];
    }

    -(IBAction)openEmail {//打开mail
    // Fire off an email to apple support


    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://devprograms@apple.com"]];


    }
    -(IBAction)openPhone {//拨打电话
    // Call Google 411


    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8004664411"]];


    }
    -(IBAction)openSms {//打开短信
    // Text to Google SMS


    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://466453"]];


    }
    -(IBAction)openBrowser {//打开浏览器
    // Lanuch any iPhone developers fav site

    [[UIApplication sharedApplication] openURL[NSURL :URLWithString:@"http://itunesconnect.apple.com"]];


    }

  • 相关阅读:
    CSS——如何清除浮动
    CSS——display(Block none inline等)属性的用法
    css3——position定位详解
    [转载]mysql创建临时表,将查询结果插入已有表中
    [转载]基于LVS的AAA负载均衡架构实践
    Percona Toolkit 2.2.19 is now available
    [转载]使用awk进行数字计算,保留指定位小数
    [转载]github在线更改mysql表结构工具gh-ost
    [转载]binlog归档
    [转载]MySQL运行状态show status详解
  • 原文地址:https://www.cnblogs.com/secbook/p/2655413.html
Copyright © 2011-2022 走看看