PeterStaev / NativeScript-Drop-Down

A NativeScript DropDown widget.
Apache License 2.0
105 stars 65 forks source link

iOS - Using with TNS 2.3.0 and Xcode 8 #34

Closed DomGaud closed 7 years ago

DomGaud commented 8 years ago

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;
PeterStaev commented 8 years ago

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

DomGaud commented 7 years ago

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.

PeterStaev commented 7 years ago

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.

creambyemute commented 7 years ago

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

bradmartin commented 7 years ago

@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);
PeterStaev commented 7 years ago

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

DomGaud commented 7 years ago

Thanks @PeterStaev