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

后端 未结 16 617
盖世英雄少女心
盖世英雄少女心 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:44

    I got the same issue when i tried to present a VC which called inside the SideMenu(jonkykong).

    first i tried inside the SideMenu and i called it from the delegate to the MainVC both had the same issue.

    Solution: dismiss the SideMenu first and present the new VC after will works perfectly!.

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

    Building on Mehrdad's answer: I had to first check if the search controller is active (if the user is currently searching):

    if self.searchController.isActive {
        self.searchController.present(alert, animated: true, completion: nil)
    } else {
        self.present(alert, animated: true, completion: nil)
    }
    

    where alert is the view controller to present modally.

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

    In my case, I tried too early to show the new UIViewController before closing the previous one. The problem was solved through a call with a slight delay:

    DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
         self.callMethod()
    }
    
    0 讨论(0)
  • 2021-02-03 17:47

    I have found out a solution.

    I have add the following code in HomeViewController.viewDidLoad and that works !

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