bazysong
bazysong

Reputation: 379

How to use size classes and autolayout in storyboard?

I am trying to use size classes and Autolayout in storyboard.

//So sorry that I cant post images for not enough reputaitons.

It seems that I've uploaded my photo successfully, and it is here now. The white area is the UIView, and only a UILable as its subview, the size class is wCompact and hRegular.

I set a UIView below the UINavigationBar, and then add a UILabel on the view. To show this on the all the iphone simulator, I user the wCompact and hRegular size classes.

I want the label to be set in the center of the screen. So I set a constrains for the label that Align horizontal center in container.

But I can't see anything on the simulator, even the UIView disappears.

Does anyone know what happened?

Upvotes: 0

Views: 295

Answers (2)

bazysong
bazysong

Reputation: 379

OK, I've found such a stupid mistake. I have't set the contrains for the UIView, so it's covered by the navigationBar...this will not happen on Xcode5, for the View is just below the UINavigationBar in the storyboard.

I tried log the UIView's frame, but I did that in the viewdidLoad method, then I got a wrong frame, because the UIView instance in the storyboard hasn't be init at that time...I should do that in the viewDidAppear method...

Tks for your answers.

Upvotes: 0

aj_f
aj_f

Reputation: 932

Maybe the height of your UIView changes? Try putting constraints to your UIView too.

Upvotes: 1

Related Questions