nativescript-modal-datetimepicker icon indicating copy to clipboard operation
nativescript-modal-datetimepicker copied to clipboard

Compatibility problems with iOS below 10

Open nunopedrosa opened this issue 7 years ago • 0 comments

There's a simple issue that breaks compatibility with iOS prior to v10, due to the use of:

https://developer.apple.com/documentation/uikit/uicontentsizecategoryadjusting/1771731-adjustsfontforcontentsizecategor

which is iOS 10.0+ only.

My suggestion is to check for iOS version and only use that attribute if version is 10+. Something in the line of:

  import * as platformModule from "tns-core-modules/platform";

  var sdkVer=  parseFloat(platformModule.device.sdkVersion);
  if (sdkVer >= 10 ) {
          titleLabel.adjustsFontForContentSizeCategory = true;
  }

or similar. Nativescript mentions graceful degradation: https://docs.nativescript.org/runtimes/ios/Requirements

but I could not find an elegant way to detect if a given attribute exists or not, instead of checking for the OS version.

Update: The "more elegant" way may be using respondsToSelector :

if (titleLabel.respondsToSelector(“adjustsFontForContentSizeCategory”)) {
               titleLabel.adjustsFontForContentSizeCategory = true;
} 

Choosing one way or the other, may be a matter of performance.

nunopedrosa avatar Mar 26 '18 17:03 nunopedrosa