Я в настоящее время работаю над customViewController
без интерфейса, разработанного в интерфейсе. Именно поэтому вы знаете, моя цель - создать layerViewController с поведением контейнера.Портретный вид в ориентированном на ландшафт устройстве
Все идет гладко, мой закрытый просмотрКонтроллеры ведут себя правильно, но есть только одно: я хочу, чтобы все это было напечатано в только в ландшафтном режиме.
Так что в моем методе инициализации программно установить кадр из моих customViewController
так:
self.view.frame = [UIScreen mainScreen].applicationFrame;
и сказать ему, что:
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
В этот момент все кажется хорошо, но есть результат :
Хотя устройство понимает, что разрешено находиться только в ландшафтном режиме, это определенно дает мне портретный взгляд. (если я удаляю метод supportedInterfaceOrientations
, вид просто отображается в портретном режиме).
Почему это происходит?
EDIT
Я пытаюсь добавить программно заданных ограничений, как следующее:
NSLayoutConstraint *topConstraint = [NSLayoutConstraint constraintWithItem:self.view attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.topLayoutGuide attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
NSLayoutConstraint *botConstraint = [NSLayoutConstraint constraintWithItem:self.view attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.bottomLayoutGuide attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
NSLayoutConstraint *leadingConstraint = [NSLayoutConstraint constraintWithItem:self.view attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.view.superview attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0];
NSLayoutConstraint *trailingConstraint = [NSLayoutConstraint constraintWithItem:self.view attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.view.superview attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:0];
[self.view addConstraints:@[topConstraint, botConstraint, leadingConstraint, trailingConstraint]];
Но не более удовлетворительный результат :(
EDIT 2
I пытался играть с myViewController.view.frame
и myViewController.view.bounds
, но ничего не помогает, мой кадр никогда не устанавливается на правильный ландшафт. Я немного потерялся на этом ...
Сообщение отредактировано, не работает. – shinyuX