ios学习--openURL的使用方法
2012-04-18 10:09
441 查看
openURL的使用方法:
view plaincopy toclipboardprint?
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:appString]];
其中系统的appString有:
view plaincopy toclipboardprint?
1.Map http://maps.google.com/maps?q=Shanghai
2.Email mailto://myname@google.com
3.Tel tel://10086
4.Msg sms://10086
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);
[[UIApplicationsharedApplication] 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 {
//拨打电话
// 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"]];
}
iphone程序内调用谷歌地图
使用CLLocationManager类,MKMapView。并且实现<MKMapViewDelegate,CLLocationManagerDelegate>
//初始化CLLocationManager,CLLocationManager获得当前地理坐标
locmanager=[[CLLocationManager alloc]init];
[locmanager setDelegate:self];
//设置精确度
[locmanager setDesiredAccuracy:kCLLocationAccuracyBest];
[locmanagerstartUpdatingLocation];
执行完以后,会自动调用代理方法:
view plaincopy toclipboardprint?
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:appString]];
其中系统的appString有:
view plaincopy toclipboardprint?
1.Map http://maps.google.com/maps?q=Shanghai
2.Email mailto://myname@google.com
3.Tel tel://10086
4.Msg sms://10086
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);
[[UIApplicationsharedApplication] 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 {
//拨打电话
// 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"]];
}
iphone程序内调用谷歌地图
使用CLLocationManager类,MKMapView。并且实现<MKMapViewDelegate,CLLocationManagerDelegate>
//初始化CLLocationManager,CLLocationManager获得当前地理坐标
locmanager=[[CLLocationManager alloc]init];
[locmanager setDelegate:self];
//设置精确度
[locmanager setDesiredAccuracy:kCLLocationAccuracyBest];
[locmanagerstartUpdatingLocation];
执行完以后,会自动调用代理方法:
相关文章推荐
- ios学习--openURL的使用方法
- [转] ios学习--openURL的使用方法
- ios学习--openURL的使用方法
- ios学习--openURL的使用方法
- IOS学习笔记(九)之UIAlertView(警告视图)和UIActionSheet(操作表视图)基本概念和使用方法
- iOS学习之UISwitch控件两种使用方法和监听
- IOS学习之UISwitch控件两种使用方法和监听
- IOS学习笔记(九)之UIAlertView(警告视图)和UIActionSheet(操作表视图)基本概念和使用方法
- iOSUI学习之使用苹果系统自带的方法处理缓存问题
- [转]IOS 学习笔记(8) 滚动视图(UIScrollView)的使用方法
- iOS9下, openURL方法无法使用?
- IOS 学习笔记(5) 控件 文本视图(UITextView)的使用方法
- IOS开发学习27 ObjectC 自带json解析方法的使用
- iOS学习之UISwitch控件两种使用方法和监听
- iOS学习之UISwitch控件两种使用方法
- iOS开发>>>openURL的使用方法
- IOS对象关系映射(ORM)之coreData框架的学习——(三)对使用步骤进行方法封装
- iOS学习之UISwitch控件两种使用方法和监听
- ios 学习笔记(8) 控件 按钮(UIButton)的使用方法
- IOS学习笔记(七)之UISegmentedControl分段控件的基本概念和使用方法