我最近遇到过这个网站,我一直试图在我的呼叫中添加一个按钮(来自图像).
网站上的代码示例工作正常,但当我尝试将相同的代码添加到我的项目时,我得不到相同的结果.
显然我错过了一些东西,但似乎无法解决这个问题!
这是我的注释代码:
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
annView.pinColor = MKPinAnnotationColorGreen;
UIButton *advertButton = [UIButton buttonWithType:UIButtonTypeCustom];
advertButton.frame = CGRectMake(0, 0, 23, 23);
advertButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
advertButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[advertButton setImage:[UIImage imageNamed:@"button_right.png"] forState:UIControlStateNormal];
[advertButton addTarget:self action:@selector(showLinks:) forControlEvents:UIControlEventTouchUpInside];
annView.rightCalloutAccessoryView = advertButton;
annView.animatesDrop=TRUE;
annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(-5, 5);
return annView;
}
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激!:)
我已将ios的Google地图sdk添加到我的Iphone应用程序中,如果点击的信息窗口弹出标题,我有一些自定义标记,如何在此信息窗口中添加按钮,如果按下将转到新页面?现在我已经尝试使用这篇文章来解决这个问题在Google Maps SDK中为InfoWindow/Marker添加点击事件以获取原生iOS /目标C它不会给我错误但它不起作用.
这就是我想要的结果:http://www.flickr.com/photos/74719051@N05/6728157477/
objective-c button google-maps-markers ios google-maps-sdk-ios
我有一个谷歌地图标记,我希望当我点击标记发送给我另一个viewController,或在我的地图上显示一个按钮,
let marker1 = GMSMarker()
marker1.position = CLLocationCoordinate2DMake(24.8236423, -107.4234671)
marker1.appearAnimation = kGMSMarkerAnimationPop
marker1.icon = UIImage(named: "flag_icon")
marker1.title = "Any title"
marker1.snippet = "Any text"
marker1.map = mapView
Run Code Online (Sandbox Code Playgroud) objective-c ×2
annotations ×1
button ×1
ios ×1
ios9 ×1
iphone ×1
mkmapview ×1
swift2 ×1
xcode7 ×1