JheeBz
JheeBz

Reputation: 313

iPhone make toolbar visible in UITableView

I have a UITableView has a subview of a UIView and I've added a toolbar on top of the UITableView so it should look like this:

enter image description here

However when I actually run it, it looks like this:

enter image description here

So for some reason the UIToolBar isn't showing up. I really don't know why, is anybody able to figure this one out? Thanks in advance.

EDIT: I've changed the simulated metrics like suggested and it still does not show up:

enter image description here

EDIT2: Here is a list of objects as requested by Raixer.

enter image description here

Upvotes: 1

Views: 1791

Answers (3)

raixer
raixer

Reputation: 1844

Alright. I have a similar setup in my app so I will show you what I did.

I setup a tab bar controller with navigation controllers in each tab (this gives me the navigation bar automatically that is why I use it). If you notice the View on the first tab is being loaded from another nib (that is what I am assuming you are doing). I did this by changing the view's class to my own view controller and then setting the name of the NIB file to load in the Inspector like this:

TabBar with Navigation
(source: minus.com)

Then in my other nib file I only have this:

Table View

I hope this helps.

Upvotes: 1

Krumelur
Krumelur

Reputation: 33048

I doubt you will succeed with this approch. UITableViewController is very picky about adding subviews to its UITableView. However, you can have your UITableView handled by a standard UIViewController (just let IB point to a custom class inheritng from UIViewController). Add the table view to the controller's view as a subview and add the toolbar to the outer view. Then you should be able to add subviews. UITableViewController gives you some convinience and functionality. If you can live without, UIViewController is no disadvantage. If you can't, you'll have to implement it yourself.

Another alternative to get the toolbar: put your table into a UINavigationController. That one comes with a toolbar (on top).

Upvotes: 0

Youssef
Youssef

Reputation: 3592

That's because you configured your nib file without counting with the height of the Tab bar.

The toolbar's height is 49 pixels. So when the view appears all your elements are moved 49 pixels up.

You should got to IB, open your View, go to Attributes Inspector, and in simulated metrics select Tab bar for Bottom Bar.

enter image description here

Upvotes: 0

Related Questions