Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After reading your comment to my first answer, I understand better what you are doing though figuring out what is going wrong is very difficult without seeing the code. I created another project with a custom tab bar controller (subclassed from <code>UIViewController</code>) where one tabbed view has a button that presents a modal view controller. When I dismiss the modal view it goes back to the tab that I was on.</p> <p>In your question you say that your view controllers managed by the tab bar are on the main window, and when you present the modal view that you bring the tab bar controller view to front. This doesn't make sense to me.</p> <p>For my example, I made <code>CustomTabBarController</code> a subclass of <code>UIViewController</code> and made instance variables for a tab bar with two tab bar items, and two view controllers. I added the tab bar and both views of the member view controllers as subviews of the <code>CustomTabBarController</code>'s view (I set the frames of the view controllers' views so they don't overlap the tab bar). I also set the <code>CustomTabBarController</code> as the delegate of the tab bar. When a tab bar item is selected I send the message <code>bringSubviewToFront:</code> to the <code>CustomTabBarController</code>'s view with the appropriate subview as the argument.</p> <p>One of the member view controllers view has a button that, when tapped, presents the modal view. The view controller could call <code>presentModalViewController:</code> when the button is tapped but, since you said that your tab bar controller is doing that, I have an IBAction method in the view controller (this is the target of the button that presents the modal view) that calls a method in <code>CustomTabBarController</code> that makes the call to <code>presentModalViewController:</code>. The view controller has an ivar for the <code>CustomTabBarController</code> (since the view controller belongs to <code>CustomTabBarController</code> this was easy to set).</p> <p>The modal view controller class also has an ivar for the <code>CustomTabBarController</code> (I set this just before calling <code>presentModalViewController:</code>) and I have a button in the modal view that dismisses the modal view. That button is hooked up to an IBAction in the modal view controller class which then calls a method in the <code>CustomTabBarController</code>.</p> <p>Everything works as expected when I do it this way. I'm sure you have you reasons for creating a custom tab bar controller but I question whether it is really necessary. I hope this helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. COHey, first thank you so much for taking the time to answer...I really appreciate! I wanted a customized tabBar because I want to manage the tab bar in a particular way. I want it to have (sometimes) nothing selected on it because more than 5 controllers are managed by the tabbar. I also want to change the height of the tabbar... anyway, I really need to have that! I also need to have sometimes the navigation bar and sometimes not so in order to have that, I had to put my controllers on the window and not on the customized tabbar controller (view). I could send it to you but can't write here...
      singulars
    2. COI don't get having nothing selected on the tab bar. If the tab bar is showing, a tab should be selected shouldn't it? Otherwise, what view is showing and how does that view relate to the tab bar? When you say you sometimes have the navigation bar and sometimes not, what does that mean specifically? Does that mean on some tab views you'll have a navigation bar and some you won't? Are you really sure that your design is correct. It sounds like your design is awkward and it could/should be done a different way. Not sure, of course, but that's the way it appears.
      singulars
    3. COI know...it seems awkward but it's not!I want to optimize my view so when something is not needed I hide it. 1)I have a table view (in one of my tabBar controller) when I tap a cell I get a new controller with the navigation bar... does it make sense to hide the navigation bar in my table view? for me it does! 2)I have a main menu with icons (like on the iPhone OS). When I tap one of these icons, I get into the controller with the tab bar but sometimes the menu is not very important so it s not present on the tab bar (with the tab bar,the user has always access to the important menus)mk sense?
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload