Monday, July 19, 2010

Hide iPhone tabbar using Monotouch C#

I will show here how to hide a tab bar for a view which is part of a tab bar controller.
I have a tab bar app which has 3 tabs(News, Account, Map)
Account tab has a table view containing 3 cells(Id Card, Meal Plan, Academics),
Clicking on Id Card cell brings another view which displays an id card.

We will remove tab bar from the bottom of the Id Card view like shown below.   

                                                                   

Lets look at the two classes associated with the parent(Account), child(Id Card) view.

StudentAccountController - This class brings the table view for the account tab and the cells associated with the view.
StudentIdController - This class brings the Id Card view.
In the RowSelected() method of Delegate class of StudentAccountController, the StudentIdController is dynamically loaded.
Here we just need to set HidesBottomBarWhenPushed property of the child view to true.

public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
{
    if(indexPath.Row == (int)itemIndex.IdCard)
    {
     StudentIdModalView studentIdVC = new StudentIdModalView();
     studentIdVC.HidesBottomBarWhenPushed = true;
     studentController.NavigationController.PushViewController(studentIdVC, true);
    }
 }

6 comments:

  1. Hello,

    I have a problem with hiding tabBar.

    I'm not using navigation controller, but have just tabBar controller with items. When I set hidesBottomBarWhenPushed to one of my controllers, nothing happens when I press that tab.

    Is it possible to use hidesBottomBarWhenPushed just with tabBar controller

    Thank you in advance.

    Cheers,

    Daniel

    ReplyDelete
  2. Daniel,
    How do you the get back to the tabs if you hide the tabbar controller when pushing one of the tabs? I'm not sure I follow your question.
    Do you have some sample code? I can take a look at it and suggest some solution.

    ReplyDelete
  3. thanks for this post, it was very helpful

    ReplyDelete
  4. i didn't get this is which type of control?
    please reply soon
    StudentIdModalView

    ReplyDelete
  5. I wrote the code like you suggested,but it shows object reference null?

    please help me

    ReplyDelete
  6. Kishore,
    Can you send me the code you have written? This is a tab bar controller.

    ReplyDelete