ios地図指定位置へジャンプ
1480 ワード
まずmyBtnというbuttonを宣言します
myButtonPressed関数
39.121.0にジャンプしました海にいるようですが
myBtn = [[UIButton alloc]initWithFrame:CGRectMake(50, 50, 100, 50)];
myBtn.backgroundColor = [UIColor grayColor];
[myBtn addTarget:self action:@selector(myButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:myBtn];
myButtonPressed関数
- (void) myButtonPressed:(id)sender{
CLLocationCoordinate2D myDst = CLLocationCoordinate2DMake(39.0, 121.0);
MKMapItem *dstLocation = [[MKMapItem alloc] initWithPlacemark:[[MKPlacemark alloc] initWithCoordinate:myDst addressDictionary:nil]];
dstLocation.name = @" ";
[MKMapItem openMapsWithItems:@[dstLocation] launchOptions:@{MKLaunchOptionsMapCenterKey:[NSNumber numberWithBool:YES]}];
39.121.0にジャンプしました海にいるようですが