Delay in presenting a modal view controller

前端 未结 9 1731
星月不相逢
星月不相逢 2020-12-24 10:51

I have a tab bar based app. There are navigation controllers in all 5 tabs with instances of custom view controller setup properly as root view controllers. This loads just

相关标签:
9条回答
  • 2020-12-24 11:11

    As per @Y.Bonafons comment, In Swift, You can try like this, (for Swift 4.x & 5.0)

    DispatchQueue.main.async {
    
                    self.showAction() //Show what you need to present
                }
    
    0 讨论(0)
  • 2020-12-24 11:13

    You should display it modally from your root vc (e.g: customTabBarRootViewController). save a reference, and use the reference controller to display it.

    0 讨论(0)
  • 2020-12-24 11:14

    If you call present(:animated:completion:) in tableView(:didSelectRowAt:), selectionStyle == .none for selected tableview cell and you’ve got this strange behavior then try to call tableView.deselectRow(at:animated:) before any operations in tableView(_:didSelectRowAt:).

    Did it help?

    0 讨论(0)
  • 2020-12-24 11:17

    Swift 4: you can use as below.

    DispatchQueue.main.async {
                let popUpVc = Utilities.viewController(name: "TwoBtnPopUpViewController", onStoryboard: "Login") as? TwoBtnPopUpViewController
                self.present(popUpVc!, animated: true, completion: nil)
            }
    

    It works for me.

    0 讨论(0)
  • 2020-12-24 11:17

    I guess you also set the cell's selectionStyle to UITableViewCellSelectionStyleNone. I change to UITableViewCellSelectionStyleDefault and it work perfect.

    0 讨论(0)
  • 2020-12-24 11:18

    Solution in Swift 3

    In the SampleSelectorViewController(the presented view controller) use the below code

    DispatchQueue.global(qos: .background).async {
    
    // Write your code
    
    }
    
    0 讨论(0)
提交回复
热议问题