当前位置: 动力学知识库 > 问答 > 编程问答 >

objective c - How can I get UIToolbar to display correctly in a static tableview?

问题描述:

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:

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?

网友答案:

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 :)

分享给朋友:
您可能感兴趣的文章:
随机阅读: