Mohammad Kamar Shad
Mohammad Kamar Shad

Reputation: 6067

How to Manage Complicated Views Hierarchy using Auto-layout in iOS Sdk

I am working on an iOS application and it will be compatible for all devices iPhone 3.5, 4, 4.7, 5.5 inches and iPad also. I am designing a screen it has 5 subviews, as i view this screen in different screen it does not resize properly. I am using Auto-layout to manage that screen and I have set the every possible constraint to manage this screen.I have to manage the Subviews height and width as the devices changes. Following are the steps taken care by me

1)Set the Equal Height Constraint for all subviews

2)Equal Width Constraint for TopView1 and TopView2 set the High priority and set the proper Horizontal spacing, Leading, trailing edges for these two top spaces accordingly.

3)Equal Width Constraint for MiddleView1 , MiddleView2 and MiddleView3 and set the High priority and set the proper Horizontal spacing for these two and vertical spaces from TOpViews accordingly.

4)Set the Width Constraint for bottomView and set the High priority and set the proper Horizontal spacing for these two and vertical spaces from MiddleViews and bottom spaces accordingly.

Prior to this i have not used auto-layout in such complicated way.

Following are the screen shotes depict my problem.

EDIT: @Ash Furrow please see attached a screen shotes with constraints.

I am laying out the base screen on Any Width Any Height

enter image description here enter image description here

enter image description here

Please anybody suggest me how should i manage this view

Upvotes: 1

Views: 450

Answers (1)

Ash Furrow
Ash Furrow

Reputation: 12421

Hmm. Looking at what you've done and the feedback to your question, everything seems correct.

I think I see the problem. The issue doesn't appear to be with your storyboard (here in case anyone is interested), but rather the use of Xcode. Instead of changing the view controller's simulated "Size" metric, use the Assistant Editor to view a preview of whatever device you want. I've tried that, and ran the code, and in both cases they appear to work.

Working

So to recap, use the Preview in the Assistant Editor instead of changing the view controller's properties to resize a view hierarchy.

Upvotes: 1

Related Questions