Reputation: 316
Is it possible to create a constraint specifically for iPhone 4s and 5s without affecting iPhone 6?
Please see image above:
The scrollview's height is with equal height with the content view. I changed the multiplier to make it 40% of the actual height of the cell.
The cell is a fix height, the same height as the main window.
If you can see on the preview on the left, there is really no space for 5s and 4s devices. So I wonder on how to approach this design issue.
Upvotes: 4
Views: 5733
Reputation: 258
Please try to use aspect ratio for all views with window view. It will calculate screen size and it will align automatically to satisfy your constraint. I had the same problem, i overcame by setting aspect ratio.
please look this, link http://mathewsanders.com/designing-adaptive-layouts-for-iphone-6-plus/
Upvotes: 4
Reputation: 21
Unfortunately you cannot do this. The solution of your problem is changing the constant
of a constraint. So I suggest you detect user's device see here how to do it and change the constraint value something like this:
-(void)viewWillLayoutSubviews {
[super viewWillLayoutSubviews];
if (IS_IPHONE_6) {
self.verticalConstraintOfButtonToTop.constant = 22;
} else if (IS_IPHONE_5) {
self.verticalConstraintOfButtonToTop.constant = 17;
}
}
or you can create separate storyboard and use it.
Also you can use Size Classes
to create universal storyboard for iPhone and iPad or portrait / landscape modes.
Upvotes: 2
Reputation: 540
I don't really understand your question. Perhaps this will help:
Constraints are like other IB items in that they can be IBOutlets. Just ctl drag from a constraint in the IB object outline to the associated view controller. In the view controller you can adjust its values in code depending on the device type.
Hope this helps.
Upvotes: 0