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″;
// URL encode the spaces
addressText = [addressText stringByAddingPercentEscapesUsingEncoding: NSASCIIStringEncoding];
NSString* urlText = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@", addressText];
// lets throw this text on the log so we can view the url in the event we have an issue
NSLog(urlText);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];
}
-(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"]];
}
openURL能帮助你运行Maps,SMS,Browser,Phone甚至其他的应用程序
最新推荐文章于 2024-10-17 19:54:01 发布