DWQA QuestionsCategory: ProgramIn IOS, one of my view controllers has other controllers. How can I find references to these controllers
Code poet taro asked 5 days ago

For example, a tabbarcontroller, how can I get the corresponding navigation controller and table view controller of the next level of navigation in this controller?

1 Answers
migrant answered 5 days ago

Tabbar controller and navigation controller are essentially controllers of container class, which can hold multiple other controllers.If you want to get a controller of tabbar controller, you can use the property of selectedviewcontroller or the viewcontrollers property. This is an array. You can get all the controllers managed by tabbar controller.Navigation controller can use rootviewcontroller and topviewcontroller to get the top and bottom controllers, or use viewcontrollers property to get an array containing all view controllers

fly2never replied 5 days ago

Yes, it is most convenient to use viewcontrollers. When traversing an array, you can use iskindofclass to determine whether it is an appropriate class or tag viewcontroller to get the desired VC