简体   繁体   中英

changing constraints for different devices in xcode

I submitted my app for approval however it got rejected because older models of the iphone and ipad do not display the app correctly. I have tried to do vary for traits but it just changes the constraints for all the devices. How can I just change the constraints for a particular device?

Hell Amanda Cohen

I highly recommend to use DeviceLayout If you use auto layout with storyboard or xib

DeviceLayout is a Swift framework that lets you set Auto Layout constraints's differently for each device what you want.

Step 1.

Inherit DeviceLayoutConstraint for your constraint that you want to set up differently following device size.

Step 2.

Setup each constraint simply for device on IBInspector

Check this. It reduce your spending time to set up layout per each device.

https://github.com/cruisediary/DeviceLayout

I do not agree with Cruz answer. But you could do that there might be use cases where that makes sense.

In my opinion you should use UIScrollViews in your screens so that smaller devices can scroll and display your content correctly.

Another thing you could do is make your constraints dependent on your screen size. For example an image has the height 1/3 of the screen size. You can achieve that by making an equal height constraint with the view of your view controller and use the multiplier field to set how much your view should have in comparison to your screen size.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM