Its the first time I need to use a Xojo delegate in iOS; or rather in general. So I wonder if Im ding something really stupid here:
In an iOS class, I created a delegate:
Protected Delegate Sub PaintMethodDelegate(w as double, h as double)
In a shared method of the same class, I use it (aSize is a NSSize structure):
Shared Function ImageFromContext(asize as FoundationFrameWork.nssize, paintmethod as ptr, opaque as boolean = false, scale as double = 1) As AppleImage
if scale = 0 then scale = AppleScreen.MainScreen.Scale
AppleCGContext.BeginImageContext(asize, opaque, Scale)
dim sp as new PaintMethodDelegate (paintmethod)
sp.Invoke (asize.width, asize.height)
dim result as appleimage = AppleCGContext.Getimage
AppleCGContext.EndImageContext
return result
End Function
And in the draw event of a view, I use the method:
dim pic as AppleImage = AppleImage.ImageFromContext (FoundationFrameWork.nsmakesize(300,450), AddressOf contextpaint)
pic.DrawAtPoint FoundationFrameWork.NSMakePoint (20,20)
Where contextpaint is
[code]Sub Contextpaint(w as double, h as double)
system.debuglog w.ToText
system.debuglog h.ToText
dim context as AppleCGBitmapContext = AppleCGBitmapContext.CurrentContext
dim p as AppleBezierPath = AppleBezierPath.PathWithOval (FoundationFrameWork.NSMakeRect (0,0,context.Width, context.height))
AppleColor.GreenColor.SetStrokeAndFill
p.FillWithBlendMode (CoreGraphicsFramework.CGBlendMode.Multiply, 0.6)
End Sub[/code]
w and h are defined and not 0 in the imagefromContext method, but in contextpaint they are always 0.
I can retrieve w and h anyway by the current context, but it would be much nicer to forward them. From the documentation, I thought this should work it doesnt. What am I doing wrong?
Also strange that the method does not work if I remove all the properties from delegate, method and Contextpaint method it crashes then.
TIA!