2016-10-08 4 views
0

iPad 용 회전 기능이있는 앱이 있습니다 (iPhone 버전은 회전이 없습니다). 스토리 보드 내 디자인에서는이 계층 구조가 있습니다 : UIView - UIScrollView - UIView. 모든 "보기"는 화면의 전체 너비로 설정됩니다. 두 번째 UIView에는 MyView으로 설정된 클래스가 있습니다.이 클래스는 외부 xib 파일입니다. 스토리 보드와 xib는 모두 세로 모드로 생성됩니다.iOS - 자동 레이아웃 회전이 예상대로 작동하지 않습니다.

지금 문제가 있습니다.

  • 가로 모드에서 앱을 실행하면 모두 제대로로드됩니다. 그 이후에 앱을 돌리면 모두 정상입니다.

  • 앱을 세로 모드로 실행하면 디자인이 "손상"됩니다. 전체 내용이 더 얇습니다 (따라서 MyView 끝과 화면 끝 사이에 약 100 + px 간격이 있습니다). 앱을 회전하면 디자인이 손상된 상태로 유지되지만 올바르게 확장됩니다. 간격은 여전히 ​​같은 크기입니다. 처음 시작하는 동안, 나는 디버거에서 다음과 같은 오류가 발생했습니다 :

    Unable to simultaneously satisfy constraints. 
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
    (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
    (
    "<NSAutoresizingMaskLayoutConstraint:0x1545b7800 h=-&- v=-&- UIView:0x1546a8cb0.width == ScrollableContentView:0x154575da0.width - 232>", 
    "<NSLayoutConstraint:0x15458dd80 H:[UIActivityIndicatorView:0x1546afa60]-(370)-| (Names: '|':UIView:0x1546ab840)>", 
    "<NSLayoutConstraint:0x15458ddd0 H:|-(361)-[UIActivityIndicatorView:0x1546afa60] (Names: '|':UIView:0x1546ab840)>", 
    "<NSLayoutConstraint:0x1546c7080 H:[UIView:0x1546ab840]-(0)-| (Names: '|':UIView:0x1546a8cb0)>", 
    "<NSLayoutConstraint:0x1546c7120 H:|-(0)-[UIView:0x1546ab840] (Names: '|':UIView:0x1546a8cb0)>", 
    "<NSLayoutConstraint:0x154579710 H:|-(0)-[ScrollableContentView:0x154575da0] (Names: '|':UIScrollView:0x15504c000)>", 
    "<NSLayoutConstraint:0x154686ef0 UIScrollView:0x15504c000.centerX == ScrollableContentView:0x154575da0.centerX>", 
    "<NSLayoutConstraint:0x154697cc0 H:[UIScrollView:0x15504c000]-(0)-| (Names: '|':UIView:0x154547b80)>", 
    "<NSLayoutConstraint:0x154697d10 H:|-(0)-[UIScrollView:0x15504c000] (Names: '|':UIView:0x154547b80)>", 
    "<NSLayoutConstraint:0x15463b8c0 'UIView-Encapsulated-Layout-Width' H:[UIView:0x154547b80(768)]>" 
    ) 
    
    Will attempt to recover by breaking constraint 
    

는 상관없이 내가 뭘,이 문제를 제거 할 수없는 생각하지 않습니다. 심지어 거의 모든 제약 조건을 삭제하더라도 동일한 문제가 있습니다.

답변

1

스토리 보드 또는 xib 파일 (문서 개요의 컨트롤러 이름 옆에 노란색/빨간색 점)에 자동 레이아웃 경고가 없는지 확인해야합니다.

아무 것도없는 경우 xib보기를 추가 할 때 제약 조건을 설정합니까?

content hugging priority 또는 content compression resistance priority에 대해 생각해 보셨습니까?

+0

레이아웃 경고/오류가 없습니다 –

+0

보기, xib 및 레이아웃 설정 코드를 추출하여 github에 둘 수 있습니까? 그렇게 쉽게 볼 수 있습니다. 또한 프로그래밍 방식으로 xib를 추가하는 것이 맞습니까? 그것을하는 동안 자동 레이아웃 제약 조건을 설정합니까? –

+0

죄송합니다. 코드/디자인은 내부적이며 앱을 판매 할 때까지 "출시"할 수 없습니다. 수동으로 xib를 추가하는 것이 아니라 속성 창에서 클래스 설정을 통해. –

관련 문제