1

I've been trying to load my headerView.xib file onto my BNRItemViewControlelr file which already has its on view.

I am just adding my headerView file onto the BNRItemViewController view. However when I look in the simulated metrics to try and to edit the size of the view there ins't a none option, instead just a freeform which still doesn't change the actual view at runtime. Is there a way I could change it?

(I can't currently post the pictures because I need 10 reputation points)

Unheilig
  • 16,196
  • 193
  • 68
  • 98
MartinSoto
  • 11
  • 1
  • Use constraints to change the size of your view. Freeform simply allows you to see the view differently in Interface Builder, it does not change the underlying view frame. – Michael May 08 '15 at 02:24
  • Oh okay but is there a way I can just change the ui view by setting the system metrics? I'm following a big nerd ranch iOS books and they just change the size option in system metrics to: none and their able to resize the view. I don't get the option none, all i get is freeform. – MartinSoto May 08 '15 at 03:36
  • The system metrics in IB is purely for visualizing certain elements in your layout, it has no bearing on the view that will be rendered after compilation unless you use the applied metrics to set constraints relative to other views. You do not change the size of a `UIView` using the system metrics. – Michael May 08 '15 at 04:09

1 Answers1

0

Just set the frame directly in the code, like this:

- (void)viewDidLoad
{
[super viewDidLoad];

[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"];

   // Adding top margin to the header view
   UIEdgeInsets inset = UIEdgeInsetsMake(20, 0, 0, 0);
   self.tableView.contentInset = inset;

   UIView *header = self.headerView;
   // making the frame for the header view
   header.frame = CGRectMake(0, 0, 400, 57);

  [self.tableView setTableHeaderView:header];
}

I actually found the answer in this stackoverflow thread: Adding constraint to a UITableVIew headerview

to add top margin: Top margin on UITableViewController

we are using UIEdgeInsets

Community
  • 1
  • 1
Nikita Vlasenko
  • 4,004
  • 7
  • 47
  • 87