Tag: uicollectionview

如何用列和行标题创buildUICollectionView?

我想创build一个如下所示的UICollectionView: 它不会被滚动或编辑。 我目前想知道如何编写这个布局。 我猜它不会是UICollectionViewFlowLayout的子类。 我可以想到很多方法,但是如果有任何“正确的”方法,我们会好奇的。 这些单元格将具有animation能力。 每行或每列应该是自己的部分?

将图像加载到UICollectionViewasynchronous?

我怎样才能加载图像到UICollectionviewasynchronous? 里面下面的方法? – (PSTCollectionViewCell *)collectionView:(PSTCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { bookImage = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@", docPath, [[preview objectAtIndex:indexPath.row] lastPathComponent]]]; [[cell grid_image] setImage:bookImage]; } 在viewdidload()我使用下面的asynchronous调用来加载图像“预览” NSMutablearray dispatch_queue_t imageLoadQueue = dispatch_queue_create("com.GMM.assamkar", NULL); dispatch_async(imageLoadQueue, ^{ //Wait for 5 seconds… usleep(1000000); docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; for(int k=0; k <[allImage count] ;k++){ imgURL = [allImage objectAtIndex:k]; [imagePreview addObject:imgURL]; imgData=[NSData […]

UICollectionView:animation自定义布局

我在UICollectionView中显示大量的图像单元格。 用一个button,我希望能够把我的所有细胞分组在第一个。 这是行之有效的,但是当我试图添加一个animation转换到我的重组行动,没有任何反应。 这里我使用自定义布局的方法: – (NSArray*)layoutAttributesForElementsInRect:(CGRect)rect { NSArray* allAttributesInRect = [super layoutAttributesForElementsInRect:rect]; if([allAttributesInRect count] > 0 && _isRegroup) { UICollectionViewLayoutAttributes *firstAttribute = [allAttributesInRect objectAtIndex:0]; CGRect frame = firstAttribute.frame; for(UICollectionViewLayoutAttributes *attribute in allAttributesInRect) [UIView animateWithDuration:0.3f animations:^{attribute.frame = frame;}]; } return allAttributesInRect; } – (void)regroupCells:(BOOL)isRegroup // This method is called from my collection controller when my button […]

UICollectionView insertItem – >调整animation时间?

所以,我有一个UICollectionView插入新项目。 我使用了Collection View编程指南中的大部分build议 – “使插入和删除animation更有趣” 有没有办法调整animation时间? (也许我只是错过了文档,但没有find任何信息) PS:如果我可以编辑也会很酷的曲线。 你知道轻松进出等等。

如何启用缩放UICollectionView

我很困惑。 我有一个UICollectionView 。 我有我自己的UICollectionViewLayout子类(喵,我没有使用Flow的东西)。 UICollectionView实例是UIScrollView的子类。 它增加了多个子视图。 但像正确缩放包含许多子视图的UIScrollView的问题似乎表明,可滚动视图应该只有一个子视图“滚动整个视图”。 对我来说似乎是一种不一致的婚姻。 我的意思是为什么苹果给我一个多重子视图的框架,然后把它们全部放在滚动视图中,这不应该工作正常? 所以我很好奇我应该如何使我的整个UICollectionView (它在UICollectionViewController子类)可缩放。 我是否需要实现各种委托方法和无效/操作布局对象,根据我在布局中保留的某些属性派生布局? 还是有其他一些机制? 另外,为什么不能只是操纵zoomScale属性,并为我自动做呢? 或者我在这里错过了一些微妙之处?

带有AutoLayout的UICollectionView Cell + UiLabel

我试图将UILabel固定到它的父级单元格。 我添加了四个约束(顶部,领先,尾随,底部) ,在iOS 8.0上运行正常,但在iOS 7.X上运行不正常 。 请看下面的图片: [点击此处查看全尺寸] 我究竟做错了什么? 请指教! 编辑#1 它似乎只是从Xcode 6通用以来就被打破了。 我的方法在Xcode 6 beta 7中工作正常。 此外,如果我减less内部视图的宽度,它会引发以下警告: 2014-09-10 19:58:28.109 Test[57827:60b] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which […]

在UICollectionView的底部加载额外的单元格

我正尝试自动获取并加载下一页的单元格,当用户滚动到UICollectionView的底部。 我能够通过在UICollectoinView页脚中添加一个UIButton来UICollectoinView 。 当用户滚动到页脚并触摸button时,新的单元格被正确添加。 可以再次触摸页脚中的UIButton来添加更多的页面。 我试图自动化,所以当用户滚动到底部时,自动调用添加新单元格的正确方法: – (UICollectionReuseableView *)collectionView: (UICollectionView *)collectionView viewForSupplementaryElementOfKind: (NSString *)kind atIndexPath: (NSIndexPath *) indexPath { // code for headerView // … // code for footerView MySupplementalFooter *footerView = nil; if ( [kind isEqual:UICollectionElementKindSectionFooter] ) { footerView = [self.collectionView dequeueReuseableSupplemntaryViewOfKind:kind withReuseIdentifier:@"FooterId" forIndexPath:indexPath]; if (LoadMoreIsEnabled) { footerView.loadMoreFooterButton.setHidden:NO]; [self loadMoreFooterButtonAction]; // calls the method […]

收集视图中的单元格中的UIButton不会触及事件内部

下面的代码expression了我的问题:(它是自包含的,你可以创build一个空模板的Xcode项目,replacemain.m文件的内容,删除AppDelegate.h / .m文件并构build它) // // main.m // CollectionViewProblem // #import <UIKit/UIKit.h> @interface Cell : UICollectionViewCell @property (nonatomic, strong) UIButton *button; @property (nonatomic, strong) UILabel *label; @end @implementation Cell – (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { self.label = [[UILabel alloc] initWithFrame:self.bounds]; self.label.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; self.label.backgroundColor = [UIColor greenColor]; self.label.textAlignment = NSTextAlignmentCenter; self.button […]

UICollectionView中的UIViewController

我有一个全屏UICollectionView在我的应用程序。 它水平滚动,每个单元格填充集合视图的边界。 集合视图由UIViewControllerpipe理。 鉴于每个“页面”是相当复杂的,它是有意义的,每个页面本身由一个关联的UIViewControllerpipe理。 iOS 5支持视图控制器遏制,以便在视图连接和分离时,子控制器应该接收适当的生命周期方法(例如, viewWillAppear:等)。 这个视图回收有多好? 从页面“1”滚动到“2”,将创build一个新的视图(因为两者都可以在触屏时同时在屏幕上)。 从页面“2”移动到“3”, UICollectionView可以成功地将页面“1”的视图出列,但是现在发生了什么? 我会像这样强制插入视图到视图控制器三? id cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ident" forIndexPath:indexPath]; UIViewController *child_controller = [self controllerAtIndexPath:indexPath]; [child_controller setView:cell]; // … and so on 这感觉不对 但是,我不能想到在这种情况下正确重用视图的正确方法。 我完全采取错误的做法吗?

在Swift中创build水平滚动collectionview

我怎样才能轻松地做一个水平滚动collectionView填充单元格横跨行而不是列下来? 我想在那里5列和3行,但有超过15个项目,我希望它滚动到下一页。 我有很多麻烦得到这个去。