How to add constraints in storyboards to superview quickly?

Currently (as being for some time now) there is no way to quickly add constraints to superview in storyboards if the superview has safe area (or is of view controller for layout guides). We can easily set them to safe area, layout guides or margins but the truth is there are way too many cases where we need to use the superview directly.


So for instance if I want to add a table view to a view controller in storyboard that will take a full screen I need to:

- Add table view to its superview
- ctrl+drag from table view to its superview to open menu

- Hold shift for multiple selection (+ hold alt for alternative menu which usues mergins) and select 4 border constraints
- Now for each way I need to manually find and select each of the constraints and either set it to superview from safe are or remove the checkbox "relative to margin" and even fix the values to 0

There is an alternative pressing the constraint tool button which is pretty similar.

In many cases we need to add a subview which takes the whole superview or needs to extend in one direction (like table view on iPhoneX should still extend beyond bottom safe area). As I mentioned there is a way to set constraints to superview but I can not be the only one that is frustrated every time that needs to do this as it takes way too long (it is honestly easier to open storyboard as xml and remove mergin there).

So is there a way around this? Is there a shortcut or a key we can set? Is there a setting which could change some defaults or something? And is there a developer that is using mergin at all (in 7+ years of iOS developmnet + some Mac I have never ever even considered using them nor have I seen a coworker using them).

Replies

Another way — which isn't quick, but quicker than changing each constraint individually — is to use the add constraints popover on the toolbar at the bottom. Uncheck "constrain to margins", then for each direction you want, click the little arrow and change from Safe Area to the superview. (That will automatically enable adding the constraint in that direction too.)