Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility problems with iOS below 10 #13

Open
nunopedrosa opened this issue Mar 26, 2018 · 0 comments
Open

Compatibility problems with iOS below 10 #13

nunopedrosa opened this issue Mar 26, 2018 · 0 comments

Comments

@nunopedrosa
Copy link

nunopedrosa commented Mar 26, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant