I am confused with the autolayout on xib/nib. I am comfortable with storyboard autolayout.
What I am trying to do is:
1. I have a storyboard with one view controller with one UIView called borderView. It is constrained correctly.It is resized correctly for iphone 5 and 6. Here is the screenshot of the storyboard:
This is the borderView in iphone 5: (I am trying to add the nib view as a subview to this border view)
2. I created a nib with UIView in it with the dimensions 300 x 300. I want this view to be added to the borderVIew in my ViewController. HEre is the screenshot for my nib.
Note: I didnt gave any height or width constraints anywhere. I just gave leading ,traliing,top and bottom.
and I am trying to add the nib to my borderview as follows:
This is the method in my viewController:
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[[NSBundle mainBundle] loadNibNamed:@"AlertView" owner:self options:nil];
[self.borderView addSubview:self.myAlertViewFromNib];
}
and the result in the iphone 5 is:
As you can see, the nib view is not aligned in the center of the screen (as the border view is aligned center to the screen).
I have no idea of how to give constraints to nib itself. Can anyone please tell me if it is possible to do it in xcode or do I need to give the constraints programmatically?