Если принятый ответ не работает ни для кого, то используйте ниже. Все коды будут одинаковыми, только измените код внутри updateViewConstraints Ссылка
- (void)updateViewConstraints {
[super updateViewConstraints];
if (self.view.frame.size.width == 0 || self.view.frame.size.height == 0)
return;
[self.inputView removeConstraint:self.heightConstraint];
CGSize screenSize = [[UIScreen mainScreen] bounds].size;
CGFloat screenH = screenSize.height;
CGFloat screenW = screenSize.width;
BOOL isLandscape = !(self.view.frame.size.width ==
(screenW*(screenWscreenH)));
NSLog(isLandscape ? @"Screen: Landscape" : @"Screen: Potriaint");
if (isLandscape)
{
self.heightConstraint = [NSLayoutConstraint constraintWithItem:self.inputView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0.0 constant: self.landscapeHeight];
[self.inputView addConstraint:self.heightConstraint];
} else {
self.heightConstraint = [NSLayoutConstraint constraintWithItem:self.inputView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0.0 constant: self.portraitHeight];
[self.inputView addConstraint:self.heightConstraint];
}
}