ios调用系统导航
#import "ViewController.h"
#import <MapKit/MapKit.h>
@interface ViewController ()
@property(nonatomic,weak)UITextField*destination;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UITextField *field=[[UITextField alloc]init];
field .frame=CGRectMake(10, 10, 100, 30);
[field becomeFirstResponder];
[self.view addSubview:field];
self.destination=field;
UIButton*btn= [UIButton buttonWithType:UIButtonTypeContactAdd];
btn.frame=CGRectMake(120, 10, 50, 20);
[btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
}
-(void)btnClick
{
CLGeocoder *geo=[[CLGeocoder alloc]init];
[geo geocodeAddressString:self.destination.text completionHandler:^(NSArray *placemarks, NSError *error) {
//地理编码后拿到地标
CLPlacemark *pm=[placemarks firstObject];
//创建MKPlacemark
MKPlacemark *mkp=[[MKPlacemark alloc]initWithPlacemark:pm];
//创建目的地对象
MKMapItem *destination=[[MKMapItem alloc]initWithPlacemark:mkp];
//获取用户当前的item
MKMapItem *current=[MKMapItem mapItemForCurrentLocation];
//2.开启导航//设置地图出行方式,设置地图类型,设置是否显示交通状况
NSDictionary *operation=@{
MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeDriving,
MKLaunchOptionsMapTypeKey:@0,
MKLaunchOptionsShowsTrafficKey:@NO};
[MKMapItem openMapsWithItems:@[current,destination] launchOptions:operation];
}];
}
@end
ios调用系统导航的更多相关文章
- ios调用系统相册、相机 显示中文标题、本地化多语言支持
因为调用系统相册.相机需要显示中文,所以搞了半天才知道是在Project->info->Custom ios Target Properties 添加 Localizations 并加入C ...
- iOS调用系统通讯录获取姓名电话号码(转)
原文地址:http://blog.csdn.net/idoshi201109/article/details/46007125 OS调用系统通讯录获取姓名电话号码 (iOS 8.0 Xcode6.3可 ...
- ios 调用系统应用的方法 应用间跳转的方法
声明一个私有方法: #pragma mark - 私有方法 -(void)openUrl:(NSString *)urlStr{ //注意url中包含协议名称,iOS根据协议确定调用哪个应用,例如发送 ...
- ios 调用系统发短信以及打电话功能
先介绍一种最简单的方法: 调用打电话功能 [[UIApplicationsharedApplication] openURL:[NSURL URLWithString:@"tel://100 ...
- iOS 调用系统拍照遇到的坑
iOS 11之前用的一套图片选择器框架,之前一直没问题,iOS11之后拍照后回调失败......,打断点方法完全执行,也能回调成功:但是去掉断点又恢复不能会调的问题.困扰了一下午,愣是没有解决.后来把 ...
- iOS - (调用系统本机打电话功能)
如下图所示,点击订单里的打电话 button 后,调用系统的打电话功能. 这个调用系统打电话功能有点简单,不需要遵守协议和代理什么的,直接在点击方法里写上几句代码就可以了. 下面来看看代码吧: 接下来 ...
- iOS - (调用系统本机发送短信功能)
今天处理一个订单详情的界面,在订单详情页面上有联系方式(电话号码),在电话号码的右边有两图片,一个是电话样式的,一个是短信样式的,做为一名程序员(号称攻城师)一眼看下去就应该是一个 button,而不 ...
- iOS调用系统声音与振动
如何调用系统声音?[iphone 调用系统铃声与震动功能] 首先要在工程里加入Audio Toolbox framework这个库,然后在需要调用的文件里#import <AudioToolbo ...
- ios调用系统界面显示英文
调用系统相册界面 UIImagePickerController *picker = [[UIImagePickerController alloc] init]; picker.sourceType ...
随机推荐
- poj 1562
这道题主要注意输入的问题,以及对周围搜索时的注意,要使用递归,多次调用,附上一组数据 11 20*@*@*@@@**@*@**@@@*****@*@*@*@*@****@**@*@*@*@*@*@*@ ...
- struts2 复杂参数封装
1.1.1 Struts2中封装复杂类型的数据: 封装到List集合: 页面: 商品名称:<input type="text" name="products[ ...
- linux skill
linux console终端乱码解决 1.console终端乱码 在/etc/profile文件的最后一行添加如下内容: export LC_ALL="zh_CN.GB18030" ...
- centos7精简版(minimal)killall: command not found
centos7精简版(minimal)运行killall命令提示 command not found 是由于没有安装psmisc所致 Psmisc软件包包含三个帮助管理/proc目录的程序. 安装下列 ...
- Light OJ 1140
数位dp,需要记录前导0. 数位dp中需要注意统计0,00,000……这些数字. 数位dp的写法可以分为两类.由于我们通常采用记忆化搜索的方式进行dp,所以我们有一个记忆化数组. 一种是记忆化数组的意 ...
- selenium使用actions.moveToElement处理菜单
//should set firefox path //FirefoxBinary binary=new FirefoxBinary(new File("C:\\Program Files ...
- Tesseract-OCR 3.05 躲过语言文字识别(运行程序+中英日韩语言包)
最新版本 静态编译 tesseract 3.05.00dev leptonica-1.73 libgif 5.1.3 : libjpeg 8c : libpng 1.6.16 : libtiff 3. ...
- 将项目导入eclipse中出现的jsp页面报错解决
- 【leetcode】Decode Ways(medium)
A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' - ...
- 【linux】学习4
文件压缩: gzip :压缩 解压缩 zcat: 读取压缩文件 gzip text1 :压缩text1 得到 text1.gz 原文件不见了 gzip -c text1 > text1.g ...