NativeScript-Drop-Down icon indicating copy to clipboard operation
NativeScript-Drop-Down copied to clipboard

iOS - Using with TNS 2.3.0 and Xcode 8

Open DomGaud opened this issue 10 years ago • 7 comments

After updating to Nativescript 2.3.0 and Xcode 8, I get the following error:

TypeError: UIScreen.mainScreen is not a function. (In 'UIScreen.mainScreen()', 'UIScreen.mainScreen' is an instance of UIScreen)

Solution - change from using a method:

var applicationFrame = UIScreen.mainScreen().applicationFrame;

to a property

var applicationFrame = UIScreen.mainScreen.applicationFrame;

DomGaud avatar Sep 16 '16 03:09 DomGaud

Thanks @DomGaud , for now I will wait for {N} to fully support XCode8 before incorporating the fix in master.

PeterStaev avatar Sep 16 '16 06:09 PeterStaev

After finding similar cases with other modules, I suggest using utils.ios.getter().

So something like this:

var application = utils.ios.getter(UIScreen, UIScreen.mainScreen)
var applicationFrame = application.applicationFrame

This checks if the property is a function and if it is, calls it on this. Designed to support backward compatibility for methods that became properties. Hence it works with both iOS10 and previous iOS versions. I have tested this using iOS8 as well.

DomGaud avatar Sep 29 '16 23:09 DomGaud

Hey @DomGaud , thanks for the suggestion! I was already planning to change t that but this function is not yet available in the publicly released NPM modules. They are probably going to release it with 2.4 so that's when will update the DropDown.

PeterStaev avatar Sep 30 '16 06:09 PeterStaev

I actually fixed it locally for me with the answer from @DomGaud and I'm on nativescript 2.3.

creambyemute avatar Oct 11 '16 11:10 creambyemute

@PeterStaev the utility is in 2.3 👍 just hit this today. I've had to use it in a few plugins already.

var utils = require('utils/utils');
var screen = utils.ios.getter(UIScreen, UIScreen.mainScreen);

bradmartin avatar Nov 04 '16 22:11 bradmartin

Thanks guys! Somehow when I initially looked at the definitions I was not seeing the getter() function... New version is now on npm.

PeterStaev avatar Nov 05 '16 12:11 PeterStaev

Thanks @PeterStaev

DomGaud avatar Nov 06 '16 22:11 DomGaud