Matias
Matias

Reputation: 551

Place UITableView below Navigation bar with Interface Builder

I am developing a storyboard with the following scenario: a Navigation Controller has UITableViewController (Father). There is a cell in Father which performs a segue that opens a new UIViewController: Son. Inside Son, I have dragged a UITableView and a Navigation Item, as I want to have a refresh button in the navigation bar.

However, when I run the project, the table doesn't fit below the navigation bar. Also, it appears to be an empty space in the footer of the view. What attribute should I set or modify, in the interface builder, to get the table begin after the navigation bar, and fill the entire view?

enter image description here

Upvotes: 1

Views: 634

Answers (2)

Matias
Matias

Reputation: 551

The solution was pretty simple, just needed to include the following line:

    self.navigationController.navigationBar.translucent = NO;

Upvotes: 0

gyan
gyan

Reputation: 219

You need not manually drag a navigation to your "son" controller. Just specify the type of the segue to be "show", and your "son" controller should inherit the navigation bar from the parent controller.

As for the refresh button, you can create one in code and add it to the navigation bar like:

self.refreshButton=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(resetButtonTapped:)];

self.navigationItem.rightBarButtonItem=self.refreshButton

Upvotes: 1

Related Questions