Thanks Nic. Using UILabels now.
Guido On 11 February 2014 04:26, Nic Wise <[email protected]> wrote: > If you Apple-D on the DrawString method to decompile it, you'll see > it's ios7 only > > [Since (7, 0), CompilerGenerated] > public static void DrawString (this NSString This, PointF point, > UIStringAttributes attributes) > { > This.WeakDrawString (point, attributes.Dictionary); > } > > I suspect it's calling > > } > Messaging.void_objc_msgSend_PointF_IntPtr (This.Handle, > Selector.GetHandle ("drawAtPoint:withAttributes:"), point, > attributes.Handle); > } > > Which is iOS7 only: > > https://developer.apple.com/library/ios/documentation/uikit/reference/NSString_UIKit_Additions/Reference/Reference.html#//apple_ref/occ/instm/NSString/drawAtPoint:withAttributes: > > Availability > > Available in iOS 7.0 and later. > > > > On Tue, Feb 11, 2014 at 9:13 AM, Guido Van Hoecke <[email protected]> wrote: >> Guido Van Hoecke <[email protected]> writes: >> >>> Guido Van Hoecke <[email protected]> writes: >>> >>>> Guido Van Hoecke <[email protected]> writes: >>>> >>>>> Following method crashes on iPad. >>>> >>>> The problem might be related to the size of the font. The same code >>>> works fine on iphone, but of course uses a smaller fint there. (The game >>>> draws a character in an 8x8 grid, which means cell size and thus font >>>> size is much smaller on iphone) >>> >>> The ipad runs ois 5.1.1, the iphone runs 7.0.4 >>> >>> This may also be important in pinpointing the bug. >> >> I filed a bug report at >> https://bugzilla.xamarin.com/show_bug.cgi?id=17691 >> >> Guido >> >>> >>> Guido >>> >>>>> >>>>> private void DrawChar (CGContext g, RectangleF frame, string c, >>>>> StateType state) >>>>> { >>>>> var h = Convert.ToInt32 (frame.Height * .8); >>>>> var s = new NSString (c); >>>>> var size = MCiOS.TextSize (UIFont.BoldSystemFontOfSize (h), >>>>> c.ToString ()); >>>>> var p = new PointF (frame.X + (frame.Width - size.Width) / 2, >>>>> frame.Y + (frame.Height - size.Height) / 2); >>>>> var font = UIFont.BoldSystemFontOfSize(h); >>>>> Debug.Assert(font != null, "Failed to get font of size " + h); >>>>> s.DrawString (p, new UIStringAttributes { >>>>> Font = font, >>>>> ForegroundColor = _textColors [(int)state], >>>>> }); >>>>> } >>>>> >>>>> The 'Font = font' line is painted green. >>>>> >>>>> Initially I did not use the intermediate variable but changed the code >>>>> so that I could check on the font being null. Turns out it isn't: I get >>>>> {Helvetica-Bold 56}. >>>>> >>>>> The details of the exception seem to indicate that it really crashes >>>>> inside MonoTouch: >>>>> >>>>> System.ArgumentNullException: Argument cannot be null. >>>>> Parameter name: key >>>>> at MonoTouch.Foundation.DictionaryContainer.SetNativeValue >>>>> (MonoTouch.Foundation.NSString key, INativeObject value, Boolean >>>>> removeNullValue) [0x0002f] in >>>>> /Developer/MonoTouch/Source/maccore/src/Foundation/.pmcs-compat.DictionaryContainer.cs:343 >>>>> at MonoTouch.UIKit.UIStringAttributes.set_Font (MonoTouch.UIKit.UIFont >>>>> value) [0x00000] in >>>>> /Developer/MonoTouch/Source/monotouch/src/UIKit/.pmcs-compat.UIStringAttributes.cs:78 >>>>> at XOOX.Classes.PuzzleView.DrawChar (MonoTouch.CoreGraphics.CGContext >>>>> g, RectangleF frame, System.String c, StateType state) [0x000ad] in >>>>> /Users/guivho/Mono/XOOX/XOOX/Classes/PuzzleView.cs:332 >>>>> at XOOX.Classes.PuzzleView.DrawCell (RectangleF frame, System.String c, >>>>> TrailType trail, StateType state, System.Collections.Generic.List`1 dots) >>>>> [0x00066] in /Users/guivho/Mono/XOOX/XOOX/Classes/PuzzleView.cs:294 >>>>> at XOOX.Classes.PuzzleView.DrawPuzzle () [0x00163] in >>>>> /Users/guivho/Mono/XOOX/XOOX/Classes/PuzzleView.cs:163 >>>>> at XOOX.Classes.PuzzleView.Draw (RectangleF rect) [0x00002] in >>>>> /Users/guivho/Mono/XOOX/XOOX/Classes/PuzzleView.cs:112 >>>>> at at (wrapper managed-to-native) >>>>> MonoTouch.UIKit.UIApplication:UIApplicationMain >>>>> (int,string[],intptr,intptr) >>>>> at MonoTouch.UIKit.UIApplication.Main (System.String[] args, >>>>> System.String principalClassName, System.String delegateClassName) >>>>> [0x0004c] in >>>>> /Developer/MonoTouch/Source/monotouch/src/UIKit/.pmcs-compat.UIApplication.cs:38 >>>>> at XOOX.Application.Main (System.String[] args) [0x00008] in >>>>> /Users/guivho/Mono/XOOX/XOOX/Main.cs:15 >>>>> >>>>> Is there some way I can prevent this error from happening? >>>>> >>>>> >>>>> Guido >>>>> >>>>> -- >>>>> The way I understand it, the Russians are sort of a combination of evil >>>>> and >>>>> incompetence... sort of like the Post Office with tanks. >>>>> -- Emo Philips >> _______________________________________________ >> MonoTouch mailing list >> [email protected] >> http://lists.ximian.com/mailman/listinfo/monotouch > > > > -- > Nic Wise > t. +64 21 676 418 | @fastchicken > b. http://www.fastchicken.co.nz/ _______________________________________________ MonoTouch mailing list [email protected] http://lists.ximian.com/mailman/listinfo/monotouch
