My viewDidAppear is not being called as a controller

It turns out what I want to do is when I came from the 3d shortcut, forcing UITabBarControllerme to select the index, if I do it in the tab bar viewDidAppear(), the problem is that viewDidAppear()my main UIViewControllerEmbedded is not called if I click on the tab bar item again, but then if it is called. This does not happen with the rest of the drivers, I understand why this is not the first one in the list of elements in UITabBarController.

Tab bar controller: (Here it comes)

override func viewDidAppear(_ animated: Bool) {
    if goTasks {
        self.selectedIndex = 0
    } else if goTodo {
        self.selectedIndex = 2
    } else if goProjects {
        self.selectedIndex = 3
    } else if goSearch {
        self.selectedIndex = 0
    }

}

My first UIViewController: (not called by this method)

override func viewDidAppear(_ animated: Bool) {
    print("Entry")
}

Is the problem overridemethods? Any solution?

+4
source share
3

UITabBarController viewDidAppear func, ,

 override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        if goTasks {
            self.selectedIndex = 0
        } else if goTodo {
            self.selectedIndex = 2
        } else if goProjects {
            self.selectedIndex = 3
        } else if goSearch {
            self.selectedIndex = 0
        }

    }

.

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    print("Entry")
}
+5

, :

override func viewDidAppear(_ animated: Bool) {
    super.viewDidLoad() // here what i ment

    if goTasks {
        self.selectedIndex = 0
    } else if goTodo {
        self.selectedIndex = 2
    } else if goProjects {
        self.selectedIndex = 3
    } else if goSearch {
        self.selectedIndex = 0
    }

}
0
override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
    if goTasks {
        self.selectedIndex = 0
    } else if goTodo {
        self.selectedIndex = 2
    } else if goProjects {
        self.selectedIndex = 3
    } else if goSearch {
        self.selectedIndex = 0
    }
}

You need to add super.viewDidAppear (animated), hope his word now

0
source

Source: https://habr.com/ru/post/1673489/


All Articles