2013-12-17 2 views
1

현재 인터페이스 작성기로 설계된 인터페이스없이 customViewController에서 작업 중입니다. 알다시피, 내 목표는 컨테이너 동작으로 layerViewController를 얻는 것입니다.가로 방향 장치의 세로보기

모든 것이 순조롭게 진행됩니다. 내 포함 된 viewController는 올바르게 작동하지만, 한 가지만 있습니다.이 모든 것이 가로 모드 인 에 인쇄되기를 바랍니다.

self.view.frame = [UIScreen mainScreen].applicationFrame; 

하고 그것을 말해 :

그래서 내 init 메소드에 프로그래밍 방식이처럼 내 customViewController의 프레임 설정 모든 것이 잘 보이는이 시점에서

- (NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskLandscape; 
} 

을하지만 결과가있다 :

enter image description here 장치는 가로 모드에서만 허용된다는 것을 알고 있지만, 나에게 초상화 지향적 인 견해를 준다. (supportedInterfaceOrientations 메서드를 제거하면보기가 세로 모드로 표시됩니다.)

왜 일어나고 있는지?

편집

나는 다음과 같이 프로그래밍 세트 제약 조건을 추가 할 않았다

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]]; 

그러나 더 이상 만족스러운 결과 :(

편집 2

I을 myViewController.view.frame 및으로 게임을 시도했습니다.하지만 아무 도움이되지 않습니다. 내 프레임이 올바른 가로보기 프레임으로 설정되지 않습니다. 나는 이걸 좀 잃어 버렸어.

답변

1

장치 방향이 가로 모드 일 때 구성 요소가 자동 정렬되도록 UI 구성 요소를 올바르게 정렬하려면 xcode에서 제공되는 자동 레이아웃 기능을 사용해야합니다.

http://www.raywenderlich.com/50317/beginning-auto-layout-tutorial-in-ios-7-part-1

체크 아웃 이해하고 자동 레이아웃 기능에 대해 배울 수 위의 튜토리얼을.

+0

수정 사항이 게시되었습니다. 작동하지 않았습니다. – shinyuX