
- (CGSize)collectionVIEw:(UICollectionVIEw *)collectionVIEw layout:(UICollectionVIEwLayout *)collectionVIEwLayout sizeforItemAtIndexPath:(NSIndexPath *)indexPath{ return [self preferredSizeforIndexPath:indexPath];}- (CGSize)preferredSizeforIndexPath:(NSIndexPath *)indexPath { BOol isLastObjectInSection = NO; Nsstring *sectionKey = [[arrCollectionData[indexPath.section] allKeys] objectAtIndex:0]; DLog(@"SectionKey: %@",sectionKey); NSArray *arrSection = [arrCollectionData[indexPath.section] objectForKey:sectionKey]; DLog(@"ArrSection: %@",arrSection); if ( arrSection[indexPath.row] == arrSection.lastObject ) { if( arrSection.count % 2 != 0 ) { isLastObjectInSection = YES; } } CGSize cellSize = CGSizeZero; if (UIDeviceOrIEntationIsLandscape([[UIDevice currentDevice] orIEntation])) { if (isLastObjectInSection == YES) { cellSize = CGSizeMake(IPAD_BADGE_WIDTH_LANDSCAPE_WIDE,IPAD_BADGE_HEIGHT_LANDSCAPE_WIDE); } else { cellSize = CGSizeMake(IPAD_BADGE_WIDTH_LANDSCAPE,IPAD_BADGE_HEIGHT_LANDSCAPE); } } else { if (isLastObjectInSection == YES) { cellSize = CGSizeMake(IPAD_BADGE_WIDTH_WIDE,IPAD_BADGE_HEIGHT_WIDE); } else { cellSize = CGSizeMake(IPAD_BADGE_WIDTH,IPAD_BADGE_HEIGHT); } } DLog(@"CellSize: %@",NsstringFromCGSize(cellSize)); return cellSize;} 以下是收集数据的示例.
Printing description of self->arrCollectionData:<__NSArrayI 0x94bbc40>({ "march 12,2013" = ( "<FMLeafTimelineContainer: 0x94b2430>","<FMLeafTimelineContainer: 0x94b3670>" );},{ "February 25,2013" = ( "<FMLeafTimelineContainer: 0x94b4500>" );},{ "February 14,2013" = ( "<FMLeafTimelineContainer: 0x94b48f0>","<FMLeafTimelineContainer: 0x94b3a60>" );},{ "February 12,2013" = ( "<FMLeafTimelineContainer: 0x94b3ce0>","<FMLeafTimelineContainer: 0x94b2b00>" );},{ "February 4,2013" = ( "<FMCommunityTimelineContainer: 0x94b4e90>","<FMCommunityTimelineContainer: 0x94b5050>","<FMCommunityTimelineContainer: 0x94b5f70>" );},{ "January 30,2013" = ( "<FMCommunityTimelineContainer: 0x94b6ad0>","<FMCommunityTimelineContainer: 0x94b5a90>" );},{ "January 24,2013" = ( "<FMCommunityTimelineContainer: 0x94b5d00>","<FMCommunityTimelineContainer: 0x94b6d90>" );},{ "January 22,2013" = ( "<FMCommunityTimelineContainer: 0x94b6440>" );},{ "January 21,2013" = ( "<FMCommunityTimelineContainer: 0x94b6260>","<FMCommunityTimelineContainer: 0x94b62e0>","<FMCommunityTimelineContainer: 0x94b70c0>","<FMCommunityTimelineContainer: 0x94b55a0>","<FMCommunityTimelineContainer: 0x94b82d0>","<FMCommunityTimelineContainer: 0x94b78b0>" );},{ "December 20,2012" = ( "<FMCommunityTimelineContainer: 0x94b53f0>" );},{ "December 6,2012" = ( "<FMCommunityTimelineContainer: 0x94b7200>" );},{ "December 4,2012" = ( "<FMCommunityTimelineContainer: 0x94b72b0>" );},{ "November 19,2012" = ( "<FMCommunityTimelineContainer: 0x94b7ae0>" );}) 下面的图片都展示了集合视图的相同部分.
解决方法 问题是由父实例的子视图引起的,该子视图具有在实例化时分配的固定帧大小. Overrode setFrame:用于UICollectionVIEw子类以分配子视图帧的值,每次单元格出列并重新排队时调用setFrame:进行相应调整. 总结以上是内存溢出为你收集整理的ios – UICollectionView布局不一致,UICollectionViewFlowLayout全部内容,希望文章能够帮你解决ios – UICollectionView布局不一致,UICollectionViewFlowLayout所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)