Skip to content

Unable to show dialog from a modal page #1809

Closed

Description

@NordlingDev

Reporting from iOS. Calling this function from inside a modal page:

exports.selectPhoto = function() {
  dialogs.action({
    message: "Select new photo",
    cancelButtonText: "Cancel",
    actions: ["Take photo", "Select from Photos"]
  }).then(function (result) {
    console.log(result);
  });
};

Will give me the error:

Warning: Attempt to present <UIAlertController: 0x7cbd3a00> on <UIViewControllerImpl: 0x7b7a88b0> whose view is not in the window hierarchy!

What is this, and how do I fix it?

Thanks in advance!

Activity

  1. self-assigned this
    on Mar 23, 2016
  2. tsonevn commented on Mar 23, 2016

    @tsonevn
    Contributor

    Hi @NordlingArt,

    I reviewed this issue. Unfortunately I could not recreate the problem.
    Can you tell us more about the given error or sent us a simple project which shows the problem.

  3. yclau commented on Apr 7, 2016

    @yclau

    I meet this error too. In android , it work probably but in IOS , come out same error.

  4. tsonevn commented on Apr 13, 2016

    @tsonevn
    Contributor

    Hi @yclau,
    Could you give more details about the abnormality. Could you tell us more about the given error or sent us a simple project which shows the problem.

  5. yclau commented on Apr 18, 2016

    @yclau

    zzz zzzz has shared a?OneDrive?file with you. To view it, click the link below.

    https://onedrive.live.com/redir?resid=AB701A01965B0E3C!549&authkey=!AGolb1iVZauJz5U
    [https://r1.res.office365.com/owa/prem/images/dc-zip_20.png]https://onedrive.live.com/redir?resid=AB701A01965B0E3C!549&authkey=!AGolb1iVZauJz5U

    Project.ziphttps://onedrive.live.com/redir?resid=AB701A01965B0E3C!549&authkey=!AGolb1iVZauJz5U

    Hi,

    Sorry for late reply, the attachment is my example project.


    From: tsonevn notifications@github.com
    Sent: Wednesday, April 13, 2016 4:45 PM
    To: NativeScript/NativeScript
    Cc: yclau
    Subject: Re: [NativeScript/NativeScript] Calling modules inside modal pages gives "hierarchy" error (#1809)

    Hi @yclauhttps://github.com/yclau,
    Could you give more details about the abnormality. Could you tell us more about the given error or sent us a simple project which shows the problem.

    You are receiving this because you were mentioned.
    Reply to this email directly or view it on GitHubhttps://github.com//issues/1809#issuecomment-209308649

  6. tsonevn commented on Apr 18, 2016

    @tsonevn
    Contributor

    Hi @yclau ,
    Thank you for your sample project.
    I reviewed it and I confirm this is real issue. This problem is scheduled for fixing.
    I am attaching link to the project repository:
    https://github.com/tsonevn/iOSModalPageAlert.git

  7. changed the title [-]Calling modules inside modal pages gives "hierarchy" error[/-] [+]Unable to show dialog from a modal page[/+] on Apr 22, 2016
  8. added a commit that references this issue on Apr 22, 2016
    8623f4e
  9. 4 remaining items

  10. added this to the 2.0.0 milestone on Apr 22, 2016
  11. nmandyam commented on Sep 26, 2016

    @nmandyam

    I am using 2.2.1, still have this problem. How come?
    Just to clarify: we have regular modal pop-ups in the app, works well on Android. On iOS, the pop-ups show up as full-screens and, when the next page is called, app locks up. And the console shows this message of view not being in the window hierarchy.
    Is there a workaround?

  12. dlucidone commented on May 5, 2017

    @dlucidone

    I'm having the same issue is there any fix for this?

  13. tsonevn commented on May 5, 2017

    @tsonevn
    Contributor

    Hi @dlucidone,
    This issue has been fixed with NativeScript 3.0. For your convenience, I update the sample project here. You could clone it and test it on your side.

  14. BMwanza commented on Aug 3, 2018

    @BMwanza

    Hi, I've run into a similar problem on 4.1.1 I am trying to display a confirmation dialog from a modal, however, no console error appears, the dialog just simply does not display.

  15. tsonevn commented on Aug 6, 2018

    @tsonevn
    Contributor

    Hi @BMwanza,
    Can you provide more info about the error, which has appeared in the console? Also, send us a sample project, where the problem can be reproduced.

  16. t3hmrman commented on Oct 2, 2018

    @t3hmrman

    Hey I just ran into this issue while trying to work with a different library but I think what I found applies here -- the issue might be a limitation of iOS -- in my case I was trying to call .scan of the nativescript-barcodescanner project, but it will attempts to open a new modal, and at that point I had an modal already open. The error I was seeing:

    Warning: Attempt to present <QRCodeReaderViewController: 0x14fe80140> on <UINavigationControllerImpl: 0x15017b800> whose view is not in the window hierarchy!
    

    For me, I fixed this by calling this.$modal.close() in the ios case inside the modal I had open, and refactored the rest of the code as necessary.

  17. webleaf commented on Dec 8, 2018

    @webleaf

    Can someone check, does it works on iOS? I've seen message in one of the community chat, that someone can't open action dialog from modal in iOS (without any errors in console).
    I don't have enviroment to check this. But I will need it in the near future.

  18. tsonevn commented on Dec 11, 2018

    @tsonevn
    Contributor

    Hi @webleaf,
    I tested the scenario with the modal view and the dialogs with our https://github.com/NativeScript/nativescript-sdk-examples-js app and everything seems to work as expected on iOS

  19. ycherniavskyi commented on Jul 2, 2019

    @ycherniavskyi
    Contributor

    I trap into this issue with NS 5.4. Yes, the structure of my layout is not trivial, but I think that dialog must work in any circumstances.

    I extract my layout in playground.

    As you could see from source code dialog operation depends on which view modal is opened. Unfortunately, in my case have access only to topmost frame.

  20. ycherniavskyi commented on Jul 2, 2019

    @ycherniavskyi
    Contributor

    @tsonevn maybe it is better to open new issue?

  21. ycherniavskyi commented on Jul 2, 2019

    @ycherniavskyi
    Contributor

    Ups, sorry for buzzing 😊.
    Just found the solution - instead of topmost().page.showModal must be used topmost().currentPage.showModal, and everything works as expected!

  22. jelledijkstra97 commented on Jul 9, 2019

    @jelledijkstra97

    I have the issue on my Angular app. I'm opening a modal from my home page and on that modal I'm trying to open a confirm dialog, but that doesn't work. When first navigating away from the homepage, then returning back to the homepage and opening the modal + confirm, everything works as expected. The home page is lazily loaded.

  23. BMwanza commented on Aug 26, 2019

    @BMwanza

    Dialogs are not showing for me in the following case:

    I'm using the showModal() method in Modal A to go to Modal B.
    Dialogs are able to show in Modal A, but not in Modal B.

    Or maybe I am miss using the Modals? Are you able to go from Modal A to Modal B using the showModal method?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions