ios - Layout for class -


i have problem regarding link between 2 blocks of code change annotation image. new swift, having hard time trying figure on mapview. i've given code in function print string when runs, string not showing in nslog. mean that, function not being run @ all? appreciate suggestions went wrong. thank you

class viewcontroller2: uiviewcontroller {  @iboutlet var mapview: mkmapview! override func viewdidload() { super.viewdidload()  //location first pin let locationone = cllocationcoordinate2dmake(-47.016945, 167.852095)  //location map centering let locationnz = cllocationcoordinate2dmake(-43.937462, 170.507813) let span = mkcoordinatespanmake(9, 9) let region = mkcoordinateregion(center: locationnz, span: span) mapview.setregion(region, animated: true)  //create annotation 1 let annotation = mkpointannotation() annotation.coordinate = locationone annotation.subtitle = "park" annotation.title = "rakiura national park"  //add annotation map mapview.addannotation(annotation)}  override func didreceivememorywarning() { super.didreceivememorywarning()}     func mapview(mapview: mkmapview, viewforannotation annotation: mkannotation) -> mkannotationview? {  print("func") guard !annotation.iskind(of: mkuserlocation.self) else { return nil}  let annotationidentifier = "annotationidentifier"  var annotationview: mkannotationview? if let dequeuedannotationview = mapview.dequeuereusableannotationview(withidentifier: annotationidentifier) { annotationview = dequeuedannotationview annotationview?.annotation = annotation}  else {  let av = mkannotationview(annotation: annotation, reuseidentifier: annotationidentifier) av.rightcalloutaccessoryview = uibutton(type: .detaildisclosure) annotationview = av}  if let annotationview = annotationview { annotationview.canshowcallout = true annotationview.image = uiimage(named: "mapicon.png")}  return annotationview}} 

it sounds may have i forgot set delegate delegate never got called problem; should suspect when delegate method doesn't fire. try

mapview.delegate = self 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -