0
그래서 ePub 프레임 워크의 일부인 앱에서 작업하고 있습니다. 앱은 독자를보기에 포함시키고 사용자가 스 와이프하여 확대/축소 및 페이지 스크롤을 허용합니다. Im은 ePub 목록이 epub의 표지 이미지를 표시하는 셀로 collectionview에 들어 오도록 수정하려고합니다. 나는 flowlayout을위한 셀을 만들 수 있고 프레임 범위를 사용하여 셀을 만들 수 있습니다.하지만 세로에서 가로로 회전 할 때 크기와 위치를 조정하지 마십시오.회전시 UICollectionViewFlowLayout 셀 조정
//Set Collection View Cell Size and Orientation
-(CGSize)
collectionView:(UICollectionView *) collectionView
layout:(UICollectionViewLayout*)collectionViewLayout
sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
//Set Landscape size of cells
if(UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)){
CGFloat cellWidth = [[UIScreen mainScreen] bounds].size.width;
CGFloat cellHeigt = [[UIScreen mainScreen] bounds].size.height-350;
NSLog(@"Is Landscape");
return CGSizeMake(cellWidth, cellHeigt);
}
//Set Potrait size of cells
else{
NSLog(@"Is Portrait");
CGFloat cellWidth = [[UIScreen mainScreen] bounds].size.width-80;
CGFloat cellHeigt = [[UIScreen mainScreen] bounds].size.height-240;
return CGSizeMake(cellWidth, cellHeigt);
}
}
나는 그 위치를이 코드를 사용 : 세포에 대한 나의 코드는 이것이다 나는 장치를 세포를 회전 할 때
//Collection View Cell Position
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
if(UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation)){
return UIEdgeInsetsMake(0,10,0,20); // top, left, bottom, right
}
else{
return UIEdgeInsetsMake(0,20,0,20); // top, left, bottom, right
}
}
최고 경계는 프레임을 통해 이동합니다.
프레임을 어떻게 동적으로 업데이트 할 수 있습니까?
감사합니다. 내 View Controller를 어떻게 참조합니까? 나는 그것을 선언하지 않았다. 내 질문을 편집하고 전체 목록 컨트롤러의 코드를 입력해야합니까? –
예, collectionView의 데이터 소스 메소드를 놓은 viewcontroller에 넣으십시오. – KKRocks
감사합니다. 지금이 사진을 드리겠습니다. –