Warning: Attempt to present * on * which is already presenting (null)

后端 未结 16 613
盖世英雄少女心
盖世英雄少女心 2021-02-03 17:14

This is my first application for iOS.

So I have a UIVIewController with a UITableView where I have integrated a UISearchBar and a

相关标签:
16条回答
  • 2021-02-03 17:26

    I faced the same kind of problem What I did is from Interface builder selected my segue Its kind was "Present Modally" and its presentation was "Over current context"

    i changed the presentation to "Default", and then it worked for me.

    0 讨论(0)
  • 2021-02-03 17:29

    In my case I was trying to present a UIAlertController at some point in the app's lifetime after using a UISearchController in the same UINavigationController.

    I wasn't using the UISearchController correctly and forgot to set searchController.isActive = false before dismissing. Later on in the app I tried to present the alert but the search controller, though not visible at the time, was still controlling the presentation context.

    0 讨论(0)
  • 2021-02-03 17:30

    My problem was that (in my coordinator) i had presented a VC on a VC and then when i wanted to present the next VC(third one), presented the third VC from the first one which obviously makes the problem which is already presenting. make sure you are presenting the third one from the second VC.

    secondVC.present(thirdVC, animated: true, completion: nil)
    
    0 讨论(0)
  • 2021-02-03 17:32

    In my case, I found my code to present the new viewController (a UIAlertController) was being called twice.

    Check this before messing about with definesPresentationContext.

    0 讨论(0)
  • 2021-02-03 17:32

    The problem for me is that I was presenting two modals and I have to dismiss both and then execute some code in the parent window ... and then I have this error... I solved it seting this code in the dismiss o the last modal presented:

    self.dismiss(animated: true, completion: {
                    self.delegate?.callingDelegate()
                })
    

    in other words instead of just dismiss two times .. in the completion block of the first dismiss call delegate that will execute the second dismiss.

    0 讨论(0)
  • 2021-02-03 17:32

    In my case this was an issue of a button which was duplicated in Interface Builder. The original button had a touch-up handler attached, which also presented a modal view. When I then attached a touch-up handler on the copied button, I forgot to remove the copied handler from the original, causing both handlers to be fired and thus creating the warning.

    0 讨论(0)
提交回复
热议问题