Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
165
Setting font sizes on IGLabel is failing in Release mode
posted

I've got some code that's been working great, but I've noticed it crashes in release mode. After a few hours of debugging, I've nailed it down to an issue with a constant being null in release mode. The variable "IGLabelConstants.IGTextStyleFontAttributeName" is null in release mode, but not in debug mode.

Here is the relative code (the length of text is forced to 4 characters above and is not part of the issue):

if (IGLabelConstants.IGTextStyleFontAttributeName == null)
    Console.WriteLine("ERMAGOOADODF!");

NSMutableDictionary attributes1 = new NSMutableDictionary();
attributes1.Add(IGLabelConstants.IGTextStyleFontAttributeName, Constants.FONT_BigWeightDisplay_Whole);
_mainWeightDisplay.AddAttributes(attributes1, new NSRange(0, _mainWeightDisplay.Text.Length - 2));

NSMutableDictionary attributes2 = new NSMutableDictionary();
attributes2.Add( IGLabelConstants.IGTextStyleFontAttributeName, Constants.FONT_BigWeightDisplay_Decimal);
_mainWeightDisplay.AddAttributes(attributes2, new NSRange(_mainWeightDisplay.Text.Length - 1, 1));

// we make the decimal a different font to get a round decimal point
NSMutableDictionary attributes3 = new NSMutableDictionary();
attributes3.Add(IGLabelConstants.IGTextStyleFontAttributeName, Constants.FONT_BigWeightDisplay_Period);
_mainWeightDisplay.AddAttributes(attributes3, new NSRange(_mainWeightDisplay.Text.Length - 2, 1));


In the console in release mode you see the "ERMAGOOADODF!" string, however it is not null and does not throw an exception when in debug mode. 

I've tried to just pass in a hardcoded string of the same value, but that has not worked as an alternative:

attributes3.Add(NSObject.FromObject("IGTEXTFONT"), Constants.FONT_BigWeightDisplay_Period);


It looks like it only happens in release mode on a device, the emulator works fine. Please let me know if you have any suggestions, I may have to find another route for now.



Parents Reply Children
No Data