인터페이스 작성기에 UICollectionView를 만들었습니다. 나는 그것을 .h 파일로, @synthesize contactList로UICollectionView의 크기를 프로그래밍 방식으로 변경하려면 어떻게해야합니까?
으로 참조했다. 내 .m 파일에.
나는 다음과 같은 코드를 사용하여 세로 및 가로에서 약간 다른 레이아웃을 구현하기 위해 노력 :
- (void) adjustViewsForOrientation:(UIInterfaceOrientation) orientation {
if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {
UICollectionViewFlowLayout *flow = (UICollectionViewFlowLayout*)contactList.collectionViewLayout;
flow.sectionInset = UIEdgeInsetsMake(48, 80, 48, 0);
flow.minimumLineSpacing = 80;
} else if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
UICollectionViewFlowLayout *flow = (UICollectionViewFlowLayout*)contactList.collectionViewLayout;
flow.sectionInset = UIEdgeInsetsMake(48, 64, 48, 0);
flow.minimumLineSpacing = 64;
}
}
이 prefectly 작동을하지만, 나는 또한 풍경에 나는 페이지 당 2 * 3 그리드를 가지고 (크기를 변경하려면 세로로 보면 3 * 2 격자입니다. 다음과 같이 크기를 설정해 보았습니다.
CGRect frame = [contactList frame];
frame.size.width = 960;
[contactList setFrame:frame];
그러나 업데이트되지 않습니다. 오류는 없지만 뷰는 업데이트되지 않습니다. 이전과 같은 크기로 유지됩니다. 보기를 업데이트하려면 어떻게해야합니까?
'self.contactList'를 사용해 볼 수 있습니까? – Amar
@amar 여전히 업데이트되지 않습니다. – Kevin
spring-struts/autolayout을 사용하여 자동으로 크기 설정을 시도해 보셨습니까? –