0

In storyboard I draged a UIToolbar onto my static tablView. For some reason, the toolbar shows up fine in the storyboard, but when I run it, the toolbar does not show up at all. I then tried to delete it so that I could drag a new one out, but the toolbar does not even show up in my document outline - I can't select it by clicking it in storyboard either. So then I tried dragging out another toolbar and placing it on top of that one, and that one shows up, but there is a white gap at the bottom of the simulator screen:

enter image description here

enter image description here

I then deleted the second toolbar and tried a couple of solutions that I found on the net, but they all seem to be outdated and error prone. How can I make this work?

Scott
  • 39
  • 2
  • 11

1 Answers1

1

When I want to do that I use a UIViewController instead of a UITableViewController. It's easier to first add the toolBar by dragging it from the Object library then drag a tableView from the same library it will automatically fit the size of the remaining space in your scene.

If you need to implement the delegate and datasource methods you'll have to declare it

@interface MyViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
...
@end

Don't forget set MyViewController as tableView's delegate and datasource either by wiring it in the storyboard or by code if you want to use an IBOutlet for the tableView.

If you need more detail just comment :)

Moxy
  • 4,162
  • 2
  • 30
  • 49
  • I'm getting some error about illegal configuration. Here's the steps that i took. I Dragged out a viewcontroll. I dragged out a toolbar. I dragged out table view. I made a UIViewController custom class and hooked it up to the view in the identity inspector and control deraged from the tableview to the customviewcontroll.h to create an outlet. I set the custom class as the tvdelegate and datasource and hooked those up in the tableview. I'm getting an error message saying that it's an illegal configuration: Static table view are only valid when embedded in UITableViewController instances. – Scott Apr 26 '12 at 13:53
  • 1
    after doing some more research I found out that adding the toolbar is just simply a matter of declaring [self.navigationController setToolbarHidden:NO]; in viewDidLoad. – Scott Apr 26 '12 at 21:38