Reputation: 119
We have a viewController
with container view that embed TabBarController
. We have added a label control on top in viewController
with welcome text. Now we want to change the label text value according to TabBarController
called dynamically. How to change/update label text from another controller in xamarin ios native app.
Please guide.
Upvotes: 1
Views: 191
Reputation: 7510
The UITabBarController
has a delegate. From your parent view controller you want to assign the delegate to self. When the tab bar changes, update the label.
class ViewController: UIViewController, UITabBarControllerDelegate {
let mainTabBarController = UITabBarController()
let label = UILabel()
override func viewDidLoad() {
super.viewDidLoad()
// setup views
mainTabBarController.delegate = self
}
func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
if viewController == <#someViewController#> {
label.text = ""
}
// else ...
}
}
Upvotes: 1