作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 map(place1,place2)
中有多个注释图钉
我希望用户触摸引脚转到新的Viewcontroller
以获取地点描述
它有功能检测引脚以触摸它以转到descriptionViewController
吗?
这是我的代码
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
MKCoordinateRegion place1 = { {0.0, 0.0} , {0.0, 0.0} };
place1.center.latitude = 34.7037755;
place1.center.longitude = 137.7345882;
place1.span.longitudeDelta = 0.02f;
place1.span.latitudeDelta = 0.02f;
[mapView setRegion:place1 animated:YES];
Newclass *ann1 = [[Newclass alloc] init];
ann1.title = @"Place1";
ann1.subtitle = @"subtitle";
ann1.coordinate = place1.center;
[mapView addAnnotation: ann1];
MKCoordinateRegion place2 = { {0.0, 0.0} , {0.0, 0.0} };
place2.center.latitude = 34.7024461;
place2.center.longitude = 137.7297572;
place2.span.longitudeDelta = 0.02f;
place2.span.latitudeDelta = 0.02f;
[mapView setRegion:place2 animated:YES];
Newclass *ann2 = [[Newclass alloc] init];
ann2.title = @"place2";
ann2.subtitle = @"subtitle";
ann2.coordinate = place2.center;
[mapView addAnnotation:ann2];
}
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation{
MKPinAnnotationView *myPin = [[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:@"current"];
myPin.pinColor = MKPinAnnotationColorGreen;
UIButton *advertButtom = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[advertButtom addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
myPin.rightCalloutAccessoryView = advertButtom;
myPin.draggable =NO;
myPin.animatesDrop =true;
myPin.canShowCallout=YES;
return myPin;
}
-(void)button:(id)sender{
NSUserDefaults *defults = [NSUserDefaults standardUserDefaults];
UIStoryboard *storyboard = [self storyboard];
descriptionViewController *description = [storyboard instantiateViewControllerWithIdentifier:@"des"];
[self presentModalViewController:description animated:YES];
NSLog(@"touched");
NSLog(@"data %@");
}
最佳答案
你需要使用mapView方法
func mapView(mapView: MKMapView, didSelectAnnotationView view: MKAnnotationView) {
NSUserDefaults *defults = [NSUserDefaults standardUserDefaults];
UIStoryboard *storyboard = [self storyboard];
descriptionViewController *description = [storyboard instantiateViewControllerWithIdentifier:@"des"];
[self presentModalViewController:description animated:YES];
NSLog(@"touched");
NSLog(@"data %@");
}
关于ios - 触摸时如何检测另一个 MKAnnotaion 引脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35979952/
我在 map(place1,place2) 中有多个注释图钉 我希望用户触摸引脚转到新的Viewcontroller以获取地点描述 它有功能检测引脚以触摸它以转到descriptionViewCont
我是一名优秀的程序员,十分优秀!