1

I would like to create a custom UIView so I could use it among a few UIViewControllers.

I created a xib file that looks like this:

enter image description here

The Above image has UIView, and inside 3 UIButtons

  1. I created TopBar : UIView
  2. I set the view size to freeform and the status bar to no.
  3. I set the File's Owner class to TopBar
  4. I dragged the UIView (which includes the 3 UIButtons) and called it contentView
  5. I added in TabBar.m the method:

-(void)awakeFromNib {
    [[NSBundle mainBundle] loadNibNamed:@"TopBar" owner:self options:nil];
    [self addSubview: _contentView];
}

  1. I added to my UIViewController via storyboard the UIView and set its class to TopBar and its size to the UIView size in the xib

However, the result looks like this:

Why? What is wrong? (as you can see the buttons are extremely big and have spaces between them). I am supporting only Ios6 and above

enter image description here

Dejell
  • 13,947
  • 40
  • 146
  • 229

1 Answers1

2

The problem was that auto-layout was checked in the xib file of TabBar.

I deselected it and now it displayed it property

If anyone needs, this shows how to deselect it in xcode 4.6

Community
  • 1
  • 1
Dejell
  • 13,947
  • 40
  • 146
  • 229