Created
December 30, 2014 14:12
-
-
Save tomohisa/57c7009a8b0f89e852b6 to your computer and use it in GitHub Desktop.
Setting Keyboard Hight same even in Enlarged App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
self.view.translatesAutoresizingMaskIntoConstraints = NO; | |
if (self.traitCollection.userInterfaceIdiom == UIUserInterfaceIdiomPad) { | |
self.portraitHeightRate = [UIScreen mainScreen].bounds.size.width * .4 / [UIScreen mainScreen].bounds.size.height; | |
}else{ | |
if (([UIScreen mainScreen].bounds.size.width + [UIScreen mainScreen].bounds.size.height)>1100) { | |
self.portraitHeightRate = [UIScreen mainScreen].bounds.size.width * .6 / [UIScreen mainScreen].bounds.size.height; | |
} else if (([UIScreen mainScreen].bounds.size.width + [UIScreen mainScreen].bounds.size.height)>950) { | |
self.portraitHeightRate = [UIScreen mainScreen].bounds.size.width * .75 / [UIScreen mainScreen].bounds.size.height; | |
} else { | |
self.portraitHeightRate = [UIScreen mainScreen].bounds.size.width * .85 / [UIScreen mainScreen].bounds.size.height; | |
} | |
} | |
if (self.landscapeHeightRate ==0) { | |
if (self.traitCollection.userInterfaceIdiom == UIUserInterfaceIdiomPad) { | |
self.landscapeHeightRate = [UIScreen mainScreen].bounds.size.width * .45 / [UIScreen mainScreen].bounds.size.height; | |
}else{ | |
self.landscapeHeightRate = .5; | |
} | |
} | |
} | |
- (CGFloat) calcuratedHeight { | |
if (self.traitCollection.userInterfaceIdiom == UIUserInterfaceIdiomPhone) { | |
if([self isPortrait]){ | |
return ((int) (self.portraitHeightRate * [UIScreen mainScreen].bounds.size.height * self.view.bounds.size.width / [UIScreen mainScreen].bounds.size.width / 10.0))*10; | |
}else{ | |
return ((int) (self.landscapeHeightRate * [UIScreen mainScreen].bounds.size.height * self.view.bounds.size.width / [UIScreen mainScreen].bounds.size.width / 10.0))*10; | |
} | |
} | |
if (self.traitCollection.userInterfaceIdiom == UIUserInterfaceIdiomPad) { | |
if([self isPortrait]){ | |
return ((int) (self.portraitHeightRate * [UIScreen mainScreen].bounds.size.height * self.view.bounds.size.width / [UIScreen mainScreen].bounds.size.width / 10.0))*10; | |
}else{ | |
return ((int) (self.landscapeHeightRate * [UIScreen mainScreen].bounds.size.height * self.view.bounds.size.width / [UIScreen mainScreen].bounds.size.width / 10.0))*10; | |
} | |
} | |
return 200; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment