Reputation: 7924
I'm trying to achieve to display a toolbar on top of a tableview. I'm working for iOS5 with storyboards I need a toolbar because it needs to be customized in a way a navigation controller does not allow me to do. The following image shows what I want to achieve:
The left and right white arrows are what I think I can't achieve with the use of a navigationcontroller. Right now I got to display everything (The screenshot is from the iphone simulator), but my problem is that the toolbar scrolls with the table, and I would like it to stay on top. I think this is because of the way I wired up things in the storyboard. Next image shows a snapshot of what the view looks like in storyboard:
The controller is a subclass of UITableViewController. The toolbar is inside the tableview because the StoryBoard editor did not allow me to put it anywhere else.
I've tried to create a new generic view controller from the storyboard, drop a toolbar and a tableview and then set the type of the controller to my custom UITableViewController. Then the storyboard does allow me to have the toolbar on top and then the tableview. The problem is that when I run this version the program terminates with a
libc++abi.dylib: terminate called throwing an exception
So right now I don't know what to do. Is there any way I can make the toolbar stay on top? Can I accomplish my objective with a navigationcontroller (using storyboards) and thus make things easier?
Any help will be appreciated. Thanks.
Upvotes: 1
Views: 2634
Reputation: 70
Depending on how you want to behave, stationary or scrolling. You can add a subview to the
UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(0, 44, 320, toolbarHeight)];
[self.navigationController.navigationBar addSubview:myView]
In 'myView' you can add all the buttons you need. Then you can leave the first cell empty.
Upvotes: 2
Reputation: 11
Instead of using a TableViewController I would start with a simple ViewController then add a TableView and a Toolbar. It's going to take more code but I don't see how any of the "template" controllers will let you do what you want.
Upvotes: 1