[UIApplication sharedApplication] openURL

引用地址:http://www.cocoachina.com/bbs/read.php?tid=73570&page=3
openURL能帮助你运行Maps,SMS,Browser,Phone甚至其他的应用程序。这是Iphone开发中我经常需要用到的一段代码,它仅仅只有一行而已。
- (IBAction)openMaps {
    //打开地图
   NSString*addressText = @"beijing";
    //@"1Infinite Loop, Cupertino, CA 95014";
   addressText =[addressTextstringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
   NSString*urlText = [NSStringstringWithFormat:@"http://maps.google.com/maps?q=%@",addressText];
   NSLog(@"urlText=============== %@", urlText);
   [[UIApplicati*****haredApplication] openURL:[NSURL URLWithString:urlText]];
}

- (IBAction)openEmail {
     //打开mail // Fire off an email to apple support
      [[UIApplication sharedApplication]openURL:[NSURL   URLWithString:@"mailto://[email protected]"]];
}

- (IBAction)openPhone {
 
    //拨打电话
    // CallGoogle 411
    [[UIApplication sharedApplication] openURL:[NSURLURLWithString:@"tel://8004664411"]];
}

- (IBAction)openSms {
    //打开短信
     // Text toGoogle SMS
    [[UIApplication sharedApplication] openURL:[NSURLURLWithString:@"sms://466453"]];
}

-(IBAction)openBrowser {
    //打开浏览器
    // Lanuch any iPhone developers fav site
     [[UIApplication sharedApplication] openURL:[NSURLURLWithString:@"http://itunesconnect.apple.com"]];
}

你可能感兴趣的:(浏览器,Objective-C)