uicollectionviewlayout

Display images in a UICollectionView - how to achieve fixed vertical spacing between images?

[亡魂溺海] 提交于 2019-12-18 11:15:08
问题 I am using a UICollectionView to present a grid of images in an iPhone app (iOS6). I am using vertical scrolling for the UICollectionView, and the images all have fixed width and varying height. The width of the images are set so that on an iPhone, it displays 3 columns of images. This works ok, and I get the images presented in a grid view. However, since my images have varying height, the vertical spacing between images in a column varies and this doesn't look very good, as you can see in

UICollection View inside Table Cell does not show images in Swift 3

这一生的挚爱 提交于 2019-12-18 09:32:12
问题 I put UICollectionView inside table cell in Home page. Each category row has their contents image. But, my problem is that when I run the app, the images under second row/second category do not show whenever I run the app. The images will show after I click more button and it will goes to details UI. Then, I click on Back button and reach the Home page. At this time, the images shows properly. I tried many codes but I don't know where it is wrong. override func viewWillLayoutSubviews() {

UICollectionView display 3 items per row

柔情痞子 提交于 2019-12-18 03:36:32
问题 I have a UICollectionView created from storyboard, I want to have 3 items per row in the view. I managed to do that using the following: - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { return CGSizeMake(collectionView.frame.size.width/3.6 , (collectionView.frame.size.height-100)/2); } However, if i have 6 items, i got 2 rows with 3 items each. But when i have 4 items, it will

UICollectionViewFlowLayout estimatedItemSize does not work properly with iOS12 though it works fine with iOS 11.*

♀尐吖头ヾ 提交于 2019-12-17 23:30:26
问题 For UICollectionView's dynamic height cells we use, if let layout = self.collectionViewLayout as? UICollectionViewFlowLayout { layout.estimatedItemSize = UICollectionViewFlowLayoutAutomaticSize } with the proper constraint of height and width, it works fine with iOS 11.* versions but it breaks and does not make the cells dynamic for iOS 12.0 回答1: In my case, I solved this by explicitly adding the following constraints to the cell's contentView. class Cell: UICollectionViewCell { // ...

UICollectionView exception in UICollectionViewLayoutAttributes from iOS7

旧巷老猫 提交于 2019-12-17 17:30:43
问题 I have done a View in CollectionView with CustomLayout. In iOS6 it worked great but iOS7 it throws an exception like this. Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'layout attributes for supplementary item at index path ( {length = 2, path = 0 - 0}) changed from CustomSupplementaryAttributes: 0xd1123a0 index path: (NSIndexPath: 0xd112580 {length = 2, path = 0 - 0}); element kind: (identifier); frame = (0 0; 1135.66 45); zIndex = -1; to

Aligning right to left on UICollectionView

可紊 提交于 2019-12-17 15:16:12
问题 this is a pretty straightforward question, but I haven't been able to find a definitive answer to it on SO (if I missed it, please correct me). Basically, my question is: Is it possible to align UICollectionView row contents from right to left instead of from left to right? In my research I've seen answers suggesting subclassing UICollectionViewFlowLayout , but I haven't been able to find an example where one was created for right-alignment. My goal is to have 2 collection views set up like

Warning: UICollectionViewFlowLayout has cached frame mismatch for index path 'abc'

☆樱花仙子☆ 提交于 2019-12-17 10:58:07
问题 This is the code causing the warning: private override func layoutAttributesForItemAtIndexPath(indexPath: NSIndexPath) -> UICollectionViewLayoutAttributes? { let attributes = super.layoutAttributesForItemAtIndexPath(indexPath) let distance = CGRectGetMidX(attributes!.frame) - self.midX; var transform = CATransform3DIdentity; transform = CATransform3DTranslate(transform, -distance, 0, -self.width); attributes!.transform3D = CATransform3DIdentity; return attributes } The console also prints:

UICollectionView Layout like SnapChat?

只愿长相守 提交于 2019-12-17 04:38:13
问题 how do we create a UICollectionViewLayout like the SnapChat's stories? Any ideas please? I'd like to have a solution without external library. 回答1: Based on a precedent answer adapted to your issue: -(id)initWithSize:(CGSize)size { self = [super init]; if (self) { _unitSize = CGSizeMake(size.width/2,80); _cellLayouts = [[NSMutableDictionary alloc] init]; } return self; } -(void)prepareLayout { for (NSInteger aSection = 0; aSection < [[self collectionView] numberOfSections]; aSection++) { /

UICollectionView Layout like SnapChat?

心已入冬 提交于 2019-12-17 04:38:00
问题 how do we create a UICollectionViewLayout like the SnapChat's stories? Any ideas please? I'd like to have a solution without external library. 回答1: Based on a precedent answer adapted to your issue: -(id)initWithSize:(CGSize)size { self = [super init]; if (self) { _unitSize = CGSizeMake(size.width/2,80); _cellLayouts = [[NSMutableDictionary alloc] init]; } return self; } -(void)prepareLayout { for (NSInteger aSection = 0; aSection < [[self collectionView] numberOfSections]; aSection++) { /

Left Align Cells in UICollectionView

隐身守侯 提交于 2019-12-17 02:21:26
问题 I am using a UICollectionView in my project, where there are multiple cells of differing widths on a line. According to: https://developer.apple.com/library/content/documentation/WindowsViews/Conceptual/CollectionViewPGforIOS/UsingtheFlowLayout/UsingtheFlowLayout.html it spreads the cells out across the line with equal padding. This happens as expected, except I want to left justify them, and hard code a padding width. I figure I need to subclass UICollectionViewFlowLayout, however after