Tag: uicollectionview

有什么办法来知道哪个集合视图单元格在特定点?

我有一个CGPoint,我想知道我的集合视图中的哪个单元格当前包含该点。 有没有简单的方法来做到这一点,或者我必须写我自己的方法?

在单元格使用AutoLayout时设置UICollectionViewCell大小

我有一个dynamic高度的UICollectionViewCell 。 它包含一个UIWebViewasynchronous加载一些内容。 加载后,它需要调整自己的大小以适应其内容。 我通过更改web view的高度约束来进行单元格大小调整。 我也发送一个委托方法到单元格调整的集合view controller ,我需要使布局无效。 但是,我得到有关冲突约束的自动布局错误。 看来收集视图正在尝试调整单元格的大小。 有谁知道如何使这个devise工作?

如何通过“created_time”在我的photosNSMutable数组中sorting我的图像,并获得我的集合视图以相应显示它们?

// // ViewController.swift // Fashun // // Created by Alex Macleod on 20/10/14. // Copyright (c) 2014 Alex Macleod. All rights reserved. // import UIKit class ViewController: UIViewController, UICollectionViewDelegateFlowLayout, UICollectionViewDataSource { var collectionView: UICollectionView? var instanceOfCustomObject: CustomObject = CustomObject() var accessToken: NSString! = "14128167.52d0add.2fbff9669d9141099597cbb8d67764a4" var userDefaults: NSUserDefaults! let colorWheel = ColorWheel() var photoCount: Int! = […]

CollectionView单元格在水平滚动之后移动到右侧

我有一个与我的CollectionView的大小相同的collectionView单元格,即一次显示一个单元格,我希望单元格之间的最小间隔为10,问题是当我滚动单元格时,单元格没有正确安装整个屏幕,并在每次滚动后增加单元格的移动。 (检查屏幕截图以便更好地理解)

离开collectionviewcell的奇怪的错误

我有一个由collectionView组成的calendarView 。 这是一个使用math计算导出的自定义calendarView 。 第七行标记星期六,这是假期,所以第七列的所有标签的字体颜色是红色的。 但是,当我滑动或导航到其他日子时,红色标签以无法追踪的随机顺序分散。 截图如下: 这是怎么发生的? 在我的dequeueReusableCell方法中,我将dequeueReusableCell单元格configuration为: cell.isHoliday = (indexPath.row + 1) % 7 == 0 ? true : false 这是我的自定义collectionViewCell假期的逻辑。 @IBOutlet var dateLabel: UILabel! @IBOutlet var englishDateLabel: UILabel! @IBOutlet var tithiLabel: UILabel! var isToday: Bool = false { didSet { self.contentView.backgroundColor = isToday ? Colors.Palette.LightGreen : UIColor.white } } var isHoliday: Bool […]

UICollectionView垂直居中

我有一个UICollectionView对象的大小(320,500)。 我需要创build一个内容垂直居中的UICollectionView 。 意思是说,如果内容的总大小是(100,100),那么单元格应该绘制自己的矩形(0,200):(320,300)。 即在50以上,在垂直中心以下250以下50。 问题是单元的数量和单元的大小只在运行时决定。 例如,如果在单元格中的文本可以是1行的大小〜(100,50)。 如果是4行大小将是〜(100,200)。 所以只有在我运行了collectionView:sizeForItemAtIndexPath:之后,才能确定最后一个单元格应该是第一个单元格的起始位置。 任何开始的build议我应该如何处理这个问题。 即使我Flowlayout了Flowlayout ,在绘制最后一个单元格之前,我将如何知道第一个单元格的位置?

集合视图单元格多项select错误

我有一个集合视图,我想select多个项目。 为此,我正在使用 – (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { [self.selectedAsset addObject:self.assets[indexPath.row]]; UICollectionViewCell* cell=[self.collectionView cellForItemAtIndexPath:indexPath]; cell.contentView.backgroundColor = [UIColor blackColor]; } 此方法将对象添加到selectedAsset NSMutableArray。 这是cellForItemAtIndexPath方法。 – (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath; { Cell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"MY_CELL" forIndexPath:indexPath]; // load the asset for this cell ALAsset *asset = self.assets[indexPath.row]; CGImageRef thumbnailImageRef = [asset thumbnail]; UIImage *thumbnail = [UIImage imageWithCGImage:thumbnailImageRef]; […]

控制UICollectionViewController中单元格之间的间隙

我的细胞似乎有20点的差距,我想控制这个价值,但每一个我发现关于这个问题的答案是行不通的。 我试过了: func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { return 0 } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { return 0 } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { return UIEdgeInsets.zero } 没有任何有用的输出,还: layout.minimumLineSpacing = 0 layout.minimumInteritemSpacing […]

如何从UIViewController访问UICollectionViewCell的IBOutlets?

我在UIViewController中实现了一个UICollectionView。 标题单元格是在一个单独的.xib文件中创build的,它通过IBOutlets和IBActions在一个单独的.h和.m文件中实现。 其余的单元格在同一个UIVIewController中实现(原因是因为我添加了这个视差效果)。 我想从包含collectionview的视图控制器(RankingViewController)修改标题单元格(CSCellUser.h)中的IBoutlets(标签和button)的信息,我该如何做到这一点? 单元格:CSCellUser.h @interface CSCellUser : UICollectionViewCell @property IBOutlet UILabel *myScoreValueLabel; @property IBOutlet UILabel *myRankingValueLabel; -(IBAction) sendButtonTouchHandler:(id) sender; @end UIViewController:RankingViewController.h @interface RankingViewController : CommonViewController <UICollectionViewDelegate, UICollectionViewDataSource> { } @property IBOutlet UICollectionView *collectionView1; @end 的UIViewController:RankingViewController.m – (void)viewDidLoad { [super viewDidLoad]; //Parallax Effect, UICollectionView // Locate the layout CSStickyHeaderFlowLayout *layout = (id)self.collectionView1.collectionViewLayout; if ([layout isKindOfClass:[CSStickyHeaderFlowLayout […]

如何在didselect上展开collectionview单元以显示更多信息?

我想animation我的collectionview单元格,以便当我触摸它时,一个mapview从它下面滑出,基本上通过将它下面的单元格向下推动,扩展到空间中。 我尝试使用这个: UICollectionView:animation单元大小更改select ,但无法让它正常工作。 在这里,我试过。 – (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { [((FeedCell *)[collectionView cellForItemAtIndexPath:indexPath]) setIsSelected:YES]; [collectionView.collectionViewLayout invalidateLayout]; __weak FeedCell *cell = (FeedCell *)[self.photoCollectionView cellForItemAtIndexPath:indexPath]; // Avoid retain cycles void (^animateChangeWidth)() = ^() { CGRect frame = cell.frame; frame.size = CGSizeMake(frame.size.width, 420); cell.frame = frame; }; // Animate [UIView transitionWithView:[collectionView cellForItemAtIndexPath:indexPath] duration:0.5f options: UIViewAnimationOptionCurveLinear animations:animateChangeWidth completion:nil]; […]