我正在放置annotation一张地图,点击图钉后,detail disclosure info button右边应该有一个,所以我可以在点击按钮后添加更多代码.但是当我运行项目时,点击引脚,没有info button显示出来.任何人都可以提供添加代码disclosure info button吗?
我的代码:
extension ViewController: MKMapView{
func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
}
Run Code Online (Sandbox Code Playgroud) 我在自己的mapkit项目中使用了自定义注释(快速3),以在地图上显示多个注释。它正在显示,我只能在第一次单击annotationn。要再次打开注释,我需要在地图上的任意位置单击,然后再次单击注释。有人可以帮助我吗?先感谢您。
这是我正在使用的功能:
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
if annotation is MKUserLocation
{
return nil
}
var annotationView = self.map.dequeueReusableAnnotationView(withIdentifier: "Pin")
if annotationView == nil{
annotationView = AnnotationView(annotation: annotation, reuseIdentifier: "Pin")
annotationView?.canShowCallout = false
}else{
annotationView?.annotation = annotation
}
if (indexPin > 0) {
indexPin = indexPin - 1
let pin : PinAnnotation = pinAnotationList[indexPin]
annotationView?.image = UIImage(named: pin.imageName)
}
return annotationView
}
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView)
{
if view.annotation is MKUserLocation
{ …Run Code Online (Sandbox Code Playgroud) 我正在尝试添加注释 MKMapView
我创建了一个CustomMapPin符合MKAnnotation协议的类
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface CustomMapPin : NSObject <MKAnnotation> {
CLLocationCoordinate2D coordinate;
NSString *title;
NSString *subtitle;
}
@property(nonatomic, assign) CLLocationCoordinate2D coordinate;
@property(nonatomic, copy) NSString *title;
@property(nonatomic, copy) NSString *subtitle;
@property(nonatomic, strong) NSString *type; // this is to differentiate between the different annotations on the map
@end
Run Code Online (Sandbox Code Playgroud)
我创建了一个类CustomMapAnnotationView,它是一个子类MKAnnotationView
CustomMapAnnotationView.h
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface CustomMapAnnotationView : MKAnnotationView
@property (nonatomic, strong) UIImageView *annotationImage;
@end
Run Code Online (Sandbox Code Playgroud)
CustomMapAnnotationView.m
#import "CustomMapAnnotationView.h"
@implementation CustomMapAnnotationView
-(id) initWithAnnotation:(id<MKAnnotation>)annotation reuseIdentifier:(NSString …Run Code Online (Sandbox Code Playgroud) 我有一个name, lon, 和的字典lat。
var places = [["name": "Angkor Wat", "lon": "103.8670", "lat": "13.4125"], ["name": "Pick up zone", "lon": "103.85771740610468", "lat": "13.41250067905404"], ["name": "66-35 Otto Rd", "lon": "-73.8889131530723", "lat": "40.706725952864886"], ["name": "40 Williams St", "lon": "-71.30756271909428", "lat": "42.64240728775266"], ["name": "324 Broadway Rd", "lon": "-71.29124543680823", "lat": "42.68061286243683"], ["name": "39 Kendall Pond Rd", "lon": "-71.33234704167283", "lat": "42.867489706954636"], ["name": "269 Treble Cove Rd", "lon": "-71.30049088921143", "lat": "42.55656906569715"]]
Run Code Online (Sandbox Code Playgroud)
这是我现在拥有的代码。
import UIKit
import MapKit
import CoreLocation
class ViewAllPinsController: …Run Code Online (Sandbox Code Playgroud)