Image not working in custom MKOverlayRenderer (RubyMotion) -


i have rubymotion app mkmapview in controller trying add image overlay to.

i'm adding overlay here (the delegate of mkmapview instance set controller itself):

image = uiimage.imagenamed("map").cgimage  lowerleft = cllocationcoordinate2dmake(21.652538062803, -127.620375523875420) upperright = cllocationcoordinate2dmake(50.406626367301044, -66.517937876818)  overlay = imageoverlay.alloc.initwithimagedata image, withlowerleftcoordinate:lowerleft,   withupperrightcoordinate:upperright self.view.addoverlay overlay 

here's custom overlay:

class imageoverlay   attr_accessor :imagedata   attr_accessor :maprect    def initwithimagedata imagedata, withlowerleftcoordinate:lowerleftcoordinate, withupperrightcoordinate:upperrightcoordinate     self.imagedata = imagedata      lowerleft = mkmappointforcoordinate(lowerleftcoordinate)     upperright = mkmappointforcoordinate(upperrightcoordinate)      self.maprect = mkmaprectmake(lowerleft.x, upperright.y, upperright.x - lowerleft.x, lowerleft.y - upperright.y)      return self   end    def coordinate     return mkcoordinateformappoint(mkmappointmake(mkmaprectgetmidx(self.maprect), mkmaprectgetmidy(self.maprect)))   end    def boundingmaprect     return self.maprect   end end 

and here custom mkoverlayrenderer:

class imageoverlayrenderer < mkoverlayrenderer    def drawmaprect maprect, zoomscale:zoomscale, incontext:context      puts "drawmaprect"      themaprect = self.overlay.boundingmaprect     therect = self.rectformaprect(themaprect)      cgcontextscalectm(context, 1.0, -1.0)     cgcontexttranslatectm(context, 0.0, -therect.size.height)      cgcontextdrawimage(context, therect, self.overlay.imagedata)   end end 

and in view controller overriding mapview:rendererforoverlay method:

def mapview mapview, rendererforoverlay:overlay    if overlay.iskindofclass(imageoverlay)     renderer = imageoverlayrenderer.alloc.initwithoverlay overlay     return renderer   end    return nil end 

the problem drawmaprect never called , app crashes no error except stating crash report may have been generated, contains this:

exception type:  exc_bad_access (sigbus) exception codes: kern_protection_failure @ 0x0000000000000000 

everything else seems work until point, mapview:rendererforoverlay invoked , returning renderer. override candrawmaprect , being invoked.

any ideas on how working?

the problem related bug in rubymotion has been fixed , made available in next release:

http://hipbyte.myjetbrains.com/youtrack/issue/rm-533

update: fix has been released in rubymotion 2.31 , have verified resolves issue.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -