2014-12-11 8 views
0

가 iOS 7과 8 사이에 차이가 나는이 하나의 UILabel 선도적 인 핀 (정규 방식이 아닌 시각적 인 형식을 사용하여) 정적 텍스트, 나는 코드에서 두 Autolayout 제약을 썼다을 보관 유지하는 포함 된 사용자 지정 UITableViewCell 그리고 라벨의 상단 가장자리를 셀의 컨테이너보기로 이동하고 iOS 7iOS 8 장치에서 작동하지만 이상한 문제는 iOS 8입니다. 레이블의 위쪽 가장자리는 컨테이너보기의 위쪽 가장자리에서 12 픽셀 떨어져 있습니다 (이것은 정확하고 예상 된 메트릭 임), iOS 8은 약 20 픽셀 이상이며 레이블의 앞 가장자리에 대해 동일한 이동이 발생합니다.자동 레이아웃 메트릭 UITableViewCells

이것은 무엇을 의미합니까? UIKit과 관련된 내용이 iOS 7iOS 8 (UITableViewCells)의 계층 구조에 숨겨진 scrollView을 포함하고 있습니까?

p.s. 제약 조건은 다음과 같습니다 어떤 도움은 매우 극명하게 될 것이다

constraint = [NSLayoutConstraint constraintWithItem:self.myLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier: 1.0 constant:12]; 
       [self.contentView addConstraint:constraint]; 


constraint = [NSLayoutConstraint constraintWithItem:self.myLabel attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeading multiplier:1.0 constant:12]; 
       [self.contentView addConstraint:constraint]; 
...

+0

시도가'label.layoutMargins = UIEdgeInsetsMake을 설정 (0, 0, 0, 0)', 아이폰 OS 8에 기본 마진은 8pt입니다. – gabbler

+0

아무 것도 변경하지 않으려 고 시도했습니다 – JAHelia

+1

참조 http://stackoverflow.com/questions/25762723/remove-separatorinset-on-ios-8-uitableview-for-xcode-6-iphone-simulator –

답변

1

내 경우에는 내가 직접 런타임에 이미지 뷰에 특정 제약 조건을 추가하는 데 필요한, 결과는 iOS7에의 다른 선도 정렬했다 (셀의 왼쪽에 완전히 부착 됨) 및 iOS8 (올바르게 정렬 됨). , 모두 선행 및 후행에 대한

enter image description here

을 :

1) 그 사람과 같이해야합니다, 당신의 tableview 선도 및 제약 후행 확인 :이 문제는 셀이 아니라도 jQuery과 제약에서뿐만 아니라이었다 때로는 뷰 컨트롤러에 테이블 뷰를 수동으로 추가 할 때 테이블 뷰의 왼쪽과 오른쪽을 정렬하는 자연스런 방법이 -16으로 설정되어 iOS 8에는 적합하지만 iOS 7에는 적합하지 않습니다.

2) 일부 제약 조건을 수정/추가합니다. 셀이 setLayoutMargins (iOS8 만)에 응답하는지 확인합니다. 경우에 제약의 상수 값을 변경

CGFloat leftMargin = 8.0; 
if ([self respondsToSelector:@selector(setLayoutMargins:)]) { 
    leftMargin = 0.0; 
} 

[self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:self.userImageView attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeadingMargin multiplier:1 constant:leftMargin]];