简体   繁体   中英

Modally Presenting a Navigation View Controller in a UITabBarController With a Segmented Control

I've spent the past few days searching on the web for a solution to my problem, however, I can't seem to find a problem similar to mine. I am using a TabBarController and on one of the tabs I have a segmented Control in the navigation bar that I would like to use to switch between view controllers. The problem is that when I present the second view Controller it appears over the tabbarcontroller. Is there anyway to keep the modally presented Navigation controller in the tabbarcontroller?

初始控制器

This is the first controller.

提出了控制器

And this is the controller I am trying to present.

well we can't really comment unless we saw some code. But I think your problem may be to do with your view hierarchy. If I was going to build what you are attempting I would do as follows:

  1. UITabbar controller that contains a custom navigation bar controller

  2. The custom nav bar controller would contain the segment controller and have a protocol defined so that a delegate could be alerted when either segment was selected by the user.

  3. The nav bar's root view controller would be a view controller that acted as a UIView container for the two screens you are displaying (friends and circle screens)

  4. This root view controller would be the delegate for the custom nav controller so that it will know when the user selected a segment.

  5. When the user selected a segment the root view controller would then switch between the friends and circles view controllers in the container.

To do the above have a look at the documentation for creating UIViewController Containers and working with delegates

Hope that helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM