You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, it turns out that NSNotFound is defined as NSIntegerMax, which on 64bit devices is the maximum value of the int64_t type. Unfortunately, JavaScript doesn't support integers this large, so NSNotFound will end up truncated and not matching the native value. JavaScript code that relies on NSNotFound will have to find workarounds.
@Fatme and I came up with such a workaround - instead of comparing the result of -[NSArray indexOfObject:] to NSNotFound, check whether the returned index is greater than zero and smaller than the count of elements in the array.
@fealebenpae Is it possible to return some other type (e.g. not a primitive JS type) which holds the native value? This way it will be possible to do comparison with it.
If we don't return a number primitive we can only return an object, and objects in JavaScript are always compared using identity equality, rather than value equality, so it wouldn't work anyway.
Just fyi I hit this in one of my apps as well. Here's the error I get when trying to use a <TabView>:
file:///app/tns_modules/ui/tab-view/tab-view.js:168:54: JS ERROR TypeError: tabBarItem.setTitlePositionAdjustment is not a function. (In 'tabBarItem.setTitlePositionAdjustment({ horizontal: 0, vertical: -20 })', 'tabBarItem.setTitlePositionAdjustment' is undefined)
@ignaciofuentes, we say that this is an iOS 9 issue, but it's the iOS 9 SDK in Xcode 7 that's the problem, not iOS 9 itself. You can build a NativeScript app with Xcode 6.4 and it will work on iOS 9, but if you build the app with Xcode 7 and run it on iOS 8 you'll get the same problem, so that's why you had the same issue on the iOS 8.4 Simulator.
I also experienced this problem while trying the tab-view example as specified in the docs it crashes with the above mentioned error. Can the docs be updated with a warning or is there an ETA on a fix for this?
This is a major challenge. Cannot debug a simple Hello World app in the iOS simulator with a TabView on an up-to-date Mac. Is there a work around that can restore TabView support before v1.5?
How do you get the master in a project? I have searched all the docs and
ReadMe files and don't see any npm or tns install to pull master. I want
this assuming the fix is in the master of course. Im sure I'm overlooking
it so any help is good to try and resolve this issue.
@bradmartin If you're just trying to fix this TabView error in a local project, just look for the tab-view.io.js file in this folder in your NativeScript project:
You should find the JS file there, and you can simply update the two lines referenced above to clear the error. This shouldn't be necessary after the next NativeScript release since the fix has been made to the TNS master branch.
Activity
fealebenpae commentedon Sep 15, 2015
The NativeScript for iOS runtime doesn't support compile-time Objective-C constants, but we're working on adding support for them.
However, it turns out that
NSNotFoundis defined asNSIntegerMax, which on 64bit devices is the maximum value of theint64_ttype. Unfortunately, JavaScript doesn't support integers this large, soNSNotFoundwill end up truncated and not matching the native value. JavaScript code that relies onNSNotFoundwill have to find workarounds.@Fatme and I came up with such a workaround - instead of comparing the result of
-[NSArray indexOfObject:]toNSNotFound, check whether the returned index is greater than zero and smaller than the count of elements in the array.hshristov commentedon Sep 15, 2015
@fealebenpae Is it possible to return some other type (e.g. not a primitive JS type) which holds the native value? This way it will be possible to do comparison with it.
fealebenpae commentedon Sep 15, 2015
If we don't return a number primitive we can only return an object, and objects in JavaScript are always compared using identity equality, rather than value equality, so it wouldn't work anyway.
Fix for issue #740.
Merge pull request #742 from NativeScript/nnikolov/iOS9SupportIssue
Fix for issue #740.
tjvantoll commentedon Sep 18, 2015
Just fyi I hit this in one of my apps as well. Here's the error I get when trying to use a
<TabView>:file:///app/tns_modules/ui/tab-view/tab-view.js:168:54: JS ERROR TypeError: tabBarItem.setTitlePositionAdjustment is not a function. (In 'tabBarItem.setTitlePositionAdjustment({ horizontal: 0, vertical: -20 })', 'tabBarItem.setTitlePositionAdjustment' is undefined)
ignaciofuentes commentedon Sep 23, 2015
As a me too fyi,
I am having the same issue as @tjvantoll. I tried this on both ios 9 and ios 8.4 emulator.
fealebenpae commentedon Sep 23, 2015
@ignaciofuentes, we say that this is an iOS 9 issue, but it's the iOS 9 SDK in Xcode 7 that's the problem, not iOS 9 itself. You can build a NativeScript app with Xcode 6.4 and it will work on iOS 9, but if you build the app with Xcode 7 and run it on iOS 8 you'll get the same problem, so that's why you had the same issue on the iOS 8.4 Simulator.
eugeneniemand commentedon Sep 23, 2015
I also experienced this problem while trying the tab-view example as specified in the docs it crashes with the above mentioned error. Can the docs be updated with a warning or is there an ETA on a fix for this?
eugeneniemand commentedon Sep 29, 2015
@fealebenpae Any idea when nativescript will support xCode 7 to circumvent the above mentioned crash using tab-view?
bradmartin commentedon Oct 1, 2015
+1
toddanglin commentedon Oct 10, 2015
This is a major challenge. Cannot debug a simple Hello World app in the iOS simulator with a TabView on an up-to-date Mac. Is there a work around that can restore TabView support before v1.5?
toddanglin commentedon Oct 10, 2015
Follow-up for those having the problem with TabView described above. Thanks to some quick sleuthing by @jbristowe this work around is available:
You need to patch your local copy of
tab-view.ios.js(in node_modules > tns-core-modules > ui > tab-view).Patch these two lines:
Line 79:
tabBarItem.titlePositionAdjustment = { horizontal: 0, vertical: -20 };Line 168:
tabBarItem.titlePositionAdjustment = { horizontal: 0, vertical: -20 };Changing from a method call to a value assignment fixes the error. Thanks @jbristowe!
jbristowe commentedon Oct 10, 2015
Looks like a fix was made a few days ago: 6a17651
bradmartin commentedon Oct 10, 2015
How do you get the master in a project? I have searched all the docs and
ReadMe files and don't see any npm or tns install to pull master. I want
this assuming the fix is in the master of course. Im sure I'm overlooking
it so any help is good to try and resolve this issue.
On 10:23pm, Fri, Oct 9, 2015 John Bristowe notifications@github.com wrote:
toddanglin commentedon Oct 10, 2015
@bradmartin If you're just trying to fix this TabView error in a local project, just look for the
tab-view.io.jsfile in this folder in your NativeScript project:(project root) > node_modules > tns-core-modules > ui > tab-view
You should find the JS file there, and you can simply update the two lines referenced above to clear the error. This shouldn't be necessary after the next NativeScript release since the fix has been made to the TNS master branch.
NathanaelA commentedon Oct 10, 2015
bradmartin commentedon Oct 10, 2015
Thanks @toddanglin and @NathanaelA
lock commentedon Aug 30, 2019
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.