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
[iOS]: frame.topmost().currentPage is not the same instance as the page being loaded in page.loaded event handler. #779
Comments
Hey, @NathanaelA , the recommended way to access the current page is by taking the object of the args parameter of page.loaded.
|
This comment was marked as abuse.
This comment was marked as abuse.
@NathanaelA - that clarified the issue :) We reproduced the problem with v1.3.0 and it is working fine. main-page.xml
main-page.js
Can you send us some code and tell which version you are using, so we can reproduce it exactly? |
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
@NathanaelA - first, I would like to point out something in the getInfo(). The method topmost() returns a Frame, so it is a bit misleading to name your variable thePage. If you would like to get the page, you can access the instance property currentPage (https://docs.nativescript.org/ApiReference/ui/frame/Frame.html). About the other problems - there is a difference how the pages are loaded in iOS and Android and that is why it crashes in iOS. What you can do is use the navigatedTo instead of loaded. |
This comment was marked as abuse.
This comment was marked as abuse.
@NathanaelA - you are totally right! We will surely discuss it in the team and work towards improving it. |
I will investigate this. |
Fixed #779: frame.topmost().currentPage is not the same instance as t…
With the new page transitions that I am about to introduce, I will have to revert this change. On both platforms the page will first be loaded and then will become the current page, since there might be a transition involved. Even if there is not transition involved the order should remain the same. |
This comment was marked as abuse.
This comment was marked as abuse.
@NathanaelA Yes. It turns out that the natural order of things will be the following on both platforms:
Also, in case you need to show modals in iOS, you should be doing it from the navigatedTo event handler from now on, since I am going to revert the ugly hack that I introduced several months ago in order to make the iOS order the same as the Android order. Since I will change the Android order once I push the Transitions Feature, the iOS order of things will no longer need to be hacked to align it with the Android version. |
This comment was marked as abuse.
This comment was marked as abuse.
After merging the Page Navigation Transitions(#1473) pull request into the master branch, the page lifecycle is now the following on both platforms.
Also, in case you need to show modals in iOS, you should be doing it from the navigatedTo event. |
@hamorphis @N3ll My problem with this is there is no good way to get the top level Page on iOS. In my app, I have 4 different tabs, which are loaded into their own files like this:
Within the js files for each tab, I have no good way of performing some operation that requires the context of the parent page. For example, if I want to do showModal from within a tab's file, I need to do something like this:
That is hacky, and creates problems when the layout changes. if I console.log currentPage, i get something like Is there still no cross platform way of getting the displayed page? |
Is this still valid? I keep getting the My page instance is from the |
same error to me: Parent page is not part of the window hierarchy. Close the current modal page before showing another one |
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. |
During page.loaded event, frame.topmost() does not have the proper information for getViewById to work. In fact currentPage = null. However on Android this does work during the page.loaded event.
This also causes a Page.showModal(x) to fail during the page.loaded event.
The text was updated successfully, but these errors were encountered: