使用未解决的标识符“相册”错误-触摸

时间:2018-09-26 08:16:27

标签: ios swift

let longPressRecogniser = UILongPressGestureRecognizer(target: self, action: #selector(MapViewController.handleLongPress(_:)))
longPressRecogniser.minimumPressDuration = 1.0
mapView.addGestureRecognizer(longPressRecogniser)

处理手势:

@objc func handleLongPress(_ gestureRecognizer : UIGestureRecognizer){
if gestureRecognizer.state != .began { return }

let touchPoint = gestureRecognizer.location(in: mapView)
let touchMapCoordinate = mapView.convert(touchPoint, toCoordinateFrom: mapView)

let album = Album(coordinate: touchMapCoordinate, context: sharedContext)

mapView.addAnnotation(album)

}

我知道

  

错误使用未解决的标识符“相册”

enter image description here

1 个答案:

答案 0 :(得分:2)

当然不是,应该是

 DateTime d1 = new DateTime(3, 10, 1); // 1 Oct 3 AD
 DateTime d2 = new DateTime(2, 8, 1);  // 1 Aug 2 AD

 DateTime result = d1
   .AddYears(d2.Year)
   .AddMonths(d2.Month);               // 1 Jun 6 AD

 // 6.6
 Console.Write($"{result.Year}.{result.Month}"); 

然后使用

class Album: NSObject, MKAnnotation {

    var coordinate = CLLocationCoordinate2DMake(0, 0)
    var title: String?
    var subtitle: String?


    init(coordinate: CLLocationCoordinate2D, title: String, subtitle: String {

        self.coordinate = coordinate
        self.title = title
        self.subtitle = subtitle
        super.init()
    }

}

并实施

let album = Album(coordinate:touchMapCoordinate, title: "myTitle", subtitle: "mySub") 
mapView.addAnnotation(album)