I have a UIView in my super view.I have set it some constraints.Now I want the size of view should be different on different devices.If I set the fix width & height then
Use Size Classes. It helps to have different settings for different devices. http://www.raywenderlich.com/83276/beginning-adaptive-layout-tutorial https://youtu.be/IwSTXY0awng?t=2m12s
Try to follow the screen shots as below:
You will get the result as below
I have written a blog article about autolayouting for dynamically changing layouts.
For each screen size you can programmatically add the constraints.
Algorithm
Changing according to orientation
The most simple way is create a Outlet of your width
and height
constraint.
Then dynamically change it in viewDidLoad
according to phone.
To check which phone it is u can check the device height like 480
for iPhone 4S ,568
for iPhone 5,5S and etc
@interface ScoreListViewController (){
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *widthConstraint;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *heightConstraint;
@end
- (void)viewDidLoad {
[super viewDidLoad];
// Set the value according to your requirement
if(4S){
self.heightConstraint.constant=100;
}
}