Katushai
Katushai

Reputation: 1520

adjusting custom uiview nib size to the size of the uiview in interface builder

I'm trying to create a custom object with interface builder. I created the object, and my plan was to add a UIView to the main view controller in which I want the object to reside. So, I dragged a UIView object into IB and went to identity inspector. I changed it to the name of my custom UIView. I expected the view to adjust its frame size to fit the frame of the object within the main view controller, but for some reason, it's not. It just appears white. I tried adding it to the view programmatically, and that worked, but i wanted to be able to do everything from interface builder, for AutoLayout purposes. Is there a way to do this? I've seen it done with the Facebook login button. simply add a UIView to the view controller, put it where you want it, change the class type in identity inspector, and it will conform to that size, while displaying the facebook login button.

Upvotes: 1

Views: 278

Answers (1)

B.R.W.
B.R.W.

Reputation: 1566

How do you initialize your UIView subclass? Using initWithFrame:? UIViews created on interface builder are instantiated by the initWithCoder: method, try using that one instead. In previous implementations of mine, that was the issue.

Upvotes: 1

Related Questions