3

I'm now doing an universal app; I faced a problems on auto layout; I need to make two views with same size on all devices; I worked on storyboard with view wAny hAny; and here the images I reach enter image description here

The problem on iPad the bottom view it's very big and I need these two vies almost same height like on the attached photo for iPhone-4inch

The following photos shown my constrains The following for top view enter image description here and the following for bottom view enter image description here

if i do equal height there's the photo enter image description here and herewith the constrains enter image description here and here the output enter image description here

here the modification as you see iPad is problem bottom view layout topView bottom View

yf526
  • 113
  • 7
Sonic
  • 518
  • 1
  • 7
  • 19

2 Answers2

1

On the upper view set left right and top constraint, on the lower view set bottom, equal width, align leading and equal Heights. Set vertial spacing between both views.

Equal spacing

iCaramba
  • 2,589
  • 16
  • 31
  • the problem on iPad; coz big view; not matching with these constrains; if i can do anything special for iPad ; advice – Sonic Jun 03 '15 at 23:05
0

If you want the two views to be the same height, give them an equal height constraint, and eliminate the constraint between the bottom view and the top of the superview. You make an equal height constraint by selecting both views and choosing "Equal Heights" from the pin menu. If you want them to not be exactly equal, you can edit that constraint to change the multiplier value to whatever you want.

rdelmar
  • 103,982
  • 12
  • 207
  • 218
  • i do this but it's not success; if you know special constrain to give for iPad only; coz the main problem on iPad; moreover if i do equal height for both views the bottom view on iPad the height will be more than the upper view – Sonic Jun 03 '15 at 22:45
  • @user3143330, If you give them equal heights, they will be equal -- if you're not seeing that, then you're doing something wrong. I can't tell what without seeing what you did. – rdelmar Jun 03 '15 at 22:46
  • i make edit for my question; please check and tell me – Sonic Jun 03 '15 at 22:53
  • The top view should not have a constraint to the bottom of the super view. The top view should have a constraint to the top of the superview, the bottom view should have one to the bottom of the superview, and there should be a space constraint between the two views. Other than the equal height constraint, there should not be any other vertical constraints. You also need to edit the equal height constraint so the multiplier is 1. – rdelmar Jun 03 '15 at 22:57
  • the problem on iPad coz iPad have a big screen; these constrain not matching with iPad; if you know a good tutorial for auto layout for universal app; please advice – Sonic Jun 03 '15 at 23:02
  • @user3143330 The problem has nothing to to with the iPad. If you add the correct constraints, as I outlined, your views will be equal heights. You should edit your question again to show your latest attempt. There are 3 videos from the WWDC 2012 on auto layout. you should watch those. – rdelmar Jun 03 '15 at 23:07
  • ok; i'll edit my question with the result; can you wait a moment – Sonic Jun 03 '15 at 23:10
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/79589/discussion-between-user3143330-and-rdelmar). – Sonic Jun 03 '15 at 23:20