objective c - Google Maps GMSGroundOverlay delegate with Swift -
i'm having issue using objective-c delegates swift. want overlay image on google maps, execute other code if overlay touched. able overlay image , display maps, can't other code execute tap event. xcode 6 doesn't autocomplete objective-c delegates swift, tried translating original work according post. know how these work?
here code:
class viewcontroller: uiviewcontroller, gmsmapviewdelegate { override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. /* mapview inital values & dependencies */ allow initiallocation = cllocationcoordinate2dmake(37.78, -122.41) allow initialdirection = cllocationdirection() allow photographic camera = gmscameraposition.camerawithtarget(initiallocation, zoom: 10) /* set mapview */ var mapview_ = gmsmapview(frame: cgrectzero) mapview_.camera = photographic camera mapview_.mylocationenabled = true self.view = mapview_ mapview_.delegate = self allow southwest = cllocationcoordinate2dmake(37.72, -122.35) allow northeast = cllocationcoordinate2dmake(37.80,-122.52) allow overlaybounds = gmscoordinatebounds(coordinate: southwest, coordinate: northeast) /* add together opacity , overlay */ var img = uiimage(named:"image.png") img = addopacity(img, 0.5) var overlay = gmsgroundoverlay(bounds: overlaybounds, icon: img) overlay.tappable = true overlay.bearing = 0 overlay.map = mapview_ } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } // - (void)mapview:(gmsmapview *)mapview didtapoverlay:(gmsoverlay *)overlay; func mapview(mapview: gmsmapview, overlay: gmsoverlay){ //other code here... }
i think more of objc->swift translation question. @ to the lowest degree when have answer:
(note did not create reply stole helpful little tool) http://objectivec2swift.net/#/converter
it reported (correctly, , in xcode's autocomplete @ 20 feb 2015)
func mapview(mapview: gmsmapview!, didtapoverlay overlay: gmsoverlay!) { } objective-c google-maps delegates swift xcode6
No comments:
Post a Comment