I have a UITableViewController and a TabBar inside of the TableView and I want to be able to display that TabBar at the bottom of the IPhone screen and not at the bottom of the Table Cells So The TabBar will always remain fixed to the screen but at the bottom.

Not sure how I can accomplish this within a Table View Controller?

The TabBar is a navigation bar to be more exact. To leave the table and go to different controllers.

Okay so I just realized I was just pulling a TabBar into the controller. So I went to the Navigation Controller and set the bottom bar in. So that takes me to my next question, how do I display that button bar in certain view controllers and not show it in others.

有帮助吗?

解决方案

Your use of UITabBar is not correct for what you are trying to accomplish. The standard use of a UITabBar is in the context of a UITabBarController.

UITabBarController doc

Here is a sample use of tab bars.

1) Create a UITabBarController and set it as the rootViewController of your window in your AppDelegate.

2) Assign the viewControllers property of the tab bar controller to be an array of the view controllers you want to be able to switch between (which you must also create).

3) You will need to do some additional research if you want to style the different aspects of the tab bar. Some things are styled by accessing the tabBar property of the UITabBarController directly. Other things (like individual tab icons and titles) are set by using the tabBarItem property of each view controller.

4) If you want to encapsulate all of this logic into one place and potentially change some of the default logic, subclass UITabBarController.

edit: your question has changed a bit and I'm not sure this answer is valid anymore. That said, it sounds like you are also misusing the UINavigationBaras this is not really its intended purpose (perhaps you meant to use a UIToolBar?)

其他提示

The problem of your code design is that you are using UITableViewController. It's view is UITableView and everything that you'll add as a subview will scroll with contents.

Quick and hack-free solution is to use:

  • UIViewController
  • Add UITableView to as a subview
  • add you TabBar (as I understood this is UINavigationBar) as a subview to your viewcontroller.view, but not to the tableview. In such way your TabBar will always be placed above your UITableView, and will not scroll.
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top