0

I have developed an app which should support both iPhone & iPad. I have designed screens using xocde 6 with autolayout. But the issue is, screens of my app looks good for iPhone but not for iPad. I have gone through This Link

It says we should use size class for iPad & design our UI for iPad. So should i use separate size class for iPad? Doing this i will again have to design the UI for iPad. So is it the best way of designing screen using auotlayout?

Mahesh Agrawal
  • 3,348
  • 20
  • 34
TechChain
  • 8,404
  • 29
  • 103
  • 228

2 Answers2

1

Yes you must do your layout independently for phone and tablet using the size class selector. A layout that works for a phone is highly unlikely to also work for tablet, or indeed iPhone 5 versus iPhone 4/6.

You may similarly need to also do landscape and portrait layouts using the size class selector if it makes sense to your project.

Try this site for great tutorials on all things iOS, including adaptive layouts.

1

If you don't want to use size class then there is a way that your screens may look good in both devices. Obviously you need to redesign the screens. If you change some of your constraints to Aspect Ratio and ProportionalWidth and ProportionalHeight and you can fix them for both devices. Suppose there is a view in the middle of controller and you want to view proper in both device then you need to add CenterX to superview, CenterY to superview, ProportionalWidth to superview and ProportionalHeight to superview. And it will look perfect in both devices. If you need further suggestion in any situation then edit your question and i will tell you which constraint you should use to look the screen proper in both devices. Thanks.

Mahesh Agrawal
  • 3,348
  • 20
  • 34
  • See my problem is i have some views on screen say some text fields & i have given them height & width say width=100 & height=20 . I have also given aspect ratio.Now it looks awesome on iPhone but on iPad height is too small i thought aspect ratio will work but it does not.Where i am wrong ?@Mahesh – TechChain Jul 01 '15 at 09:07
  • you have given height and width fixed. Thats the reason its looking small in iPad. If you are giving aspect ratio and any one out of width and height fixed then it does not means anything. Either you need to add aspect ratio to self and again aspect ratio to main view (superview which is the main root view, or any view which will not be fixed width or height for any device), or you need to use Proportional height to a superview and Proportional width to superview. – Mahesh Agrawal Jul 01 '15 at 09:12
  • But i have to give some height & width some value.Otherwise how view will be populated?Are trying trying to say should i use equal width & equal height then give multiplier value in that? – TechChain Jul 01 '15 at 09:20
  • yes exactly. By this way your view will take ratio of superview and grow according to the device size. – Mahesh Agrawal Jul 01 '15 at 09:22
  • Well that's very lengthy process. – TechChain Jul 01 '15 at 09:23
  • Look if you want to support iPad also then either you need to configure all constraints manually by coding or take ratios according to device or you can use size class and change all constraints for another type of layout specifically for iPad. This is more lengthy then what am talking about. – Mahesh Agrawal Jul 01 '15 at 09:26
  • Can we chat.I have lot o doubts? – TechChain Jul 01 '15 at 09:27
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/82065/discussion-between-mahesh-agrawal-and-deepak-kumar). – Mahesh Agrawal Jul 01 '15 at 09:28