开发者

Referencing view in tabbar app?

开发者 https://www.devze.com 2022-12-19 19:19 出处:网络
I have a tabbar based app and would like to reference one of three views.Th开发者_运维知识库ere are three tabs.When tab2 is clicked, tab2view is created.tab1view needs to reference tab2view so it can

I have a tabbar based app and would like to reference one of three views. Th开发者_运维知识库ere are three tabs. When tab2 is clicked, tab2view is created. tab1view needs to reference tab2view so it can be pushed into view. tab2view can be pushed into view via tab2 or tab1view. How do I give tab1view a reference to tab2view?

tab1view will also need to create tab2view if it hasn't already been created from a tab click.


You don't push views with UITabBarControllers, you add View Controllers to an array that get displayed when the user clicks the appropriate tab bar item. If by "push" you mean "switch to tab" then you just need to set the "selectedIndex" property of your TabBarController.

But I don't understand this dependency you have where the second tab's view controller has to be created by the first. If you're not seeing your second tab view when you click on the second tab button, then it means you're doing something wrong in building the tab bar itself.

Regardless, all view controllers in your tab bar are accessible via the "viewControllers" array so getting the second one would be:

UIViewController *secondVC = [[myTabBarController viewControllers] objectAtIndex:1];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号