Skip to content

I can't use self.presentingViewController to find the parent view controller #64

@frank61003

Description

@frank61003

Hi
I use the AZTabBarController to controller my tab bar. When I present a new view, It works well. I got an issue to bring the data back to the parent viewController. I use self.presentingViewController to get my parent view controller. but it crash at all. Below are my code in the childViewController.

 @IBAction func storeBtn(_ sender: UIButton) {
        let vc = self.presentingViewController as! MoreViewController
        vc.phoneLabel.text = "1234"
        self.dismiss(animated: true)
 }

Error message:

2020-04-14 19:24:18.058780+0800 InsuranceMasterSales[26704:24913201] Could not cast value of type 'InsuranceMasterSales.SixItemTabbarViewController' (0x10e84d178) to 'InsuranceMasterSales.MoreViewController' (0x10e84bc30).

It seems that swift get confused about the presentingViewController. How to solve this question? Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions