Tag: uicollectionview

PerfomSegue在UITableViewCell类中

我有TableView和TableView里面我已经添加了UICollectionView 。 现在,当用户点击任何UICollectionView ,我想传递数据到下一个viewController但不幸的是,我不能使用UITableViewCell类中执行segue,我已经select了项目。 有什么方法可以在这里执行吗? 整个代码 class UserLibraryViewController: UIViewController { extension UserLibraryViewController : UITableViewDelegate { } extension UserLibraryViewController : UITableViewDataSource { func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? { return myBooksGenre[section] } func numberOfSectionsInTableView(tableView: UITableView) -> Int { return myBooksGenre.count } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 1 } func […]

将一个静态单元添加到UICollectionView

我有一个UICollectionView显示数组中的单元格。 我想要第一个单元格是一个静态单元格,作为一个提示,以进入创buildstream程(最终添加一个新的单元格)。 我的做法是将两个部分添加到我的collectionView中,但是我目前无法弄清楚如何在cellForItemAtIndexPath中返回一个单元格。 这是我的尝试: func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { if indexPath.section == 0 { let firstCell = collectionView.dequeueReusableCellWithReuseIdentifier("createCell", forIndexPath: indexPath) as! CreateCollectionViewCell firstCell.imageView.backgroundColor = UIColor(white: 0, alpha: 1) return firstCell } else if indexPath.section == 1 { let cell = collectionView.dequeueReusableCellWithReuseIdentifier("mainCell", forIndexPath: indexPath) as! MainCollectionViewCell cell.imageView?.image = self.imageArray[indexPath.row] return cell } […]

dynamic调整UICollectionViewCell的大小

我有一个UICollectionView与2 UILabel和UIImage具有类似的布局: ——————– | | | LABEL1 | | IMAGE | | LABEL2 | | …… | | …… | ——————– Label2有不同数量的线条,单元格不同,我希望能够根据label2 height自动调整UICollectionView height label2 height ,让它“自动填充”单元格。 是否有可能在iOS?

xcode将文本string加载到UISearchController中

我正在使用这个例子通过UICollectionView进行search: https : //github.com/ihomam/CollectionViewWithSearchBar/blob/master/collevtionViewWithSearchBar/CollectionViewController.m – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath]; // Configure the cell if (self.searchBarActive) { cell.laName.text = self.dataSourceForSearchResult[indexPath.row]; } else { cell.laName.text = self.dataSource[indexPath.row]; } return cell; } …只有我的应用程序设置有点不同: – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { PlaceCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath]; Place *p = [_entries […]

iOS将一个CollectionView添加到storyboard UI构build器中的另一个视图

刚开始使用iOS,并试图使右侧的集合视图成为左侧视图的子视图。 我似乎无法将其拖入。我认为问题的一部分是在导航的左侧部分(工作区域的左侧),集合视图被称为场景。 为了创build我想要放入collections视图的视图,我只是将一个新的视图控制器拖到工作区域,然后按住Ctrl +单击将其添加到主选项卡视图。 我将要收集视图上方的另一个视图,但首先是事情… 我必须以编程方式执行此操作吗?

UICollection View在较小的设备上导致“UICollectionViewFlowLayoutBreakForInvalidSizes”

在iPhone 6 Plus上,收集视图单元格很好,但是当在另一个像iPhone 5的设备上testing时,我被“ 017-06-15 01:59:25.744 HyperTest [3865:8825385] UICollectionViewFlowLayout的行为未定义,因为:2017-06-15 01:59:25.744 HyperTest [3865:8825385]项目宽度必须小于UICollectionView的宽度减去左侧和右侧的值,减去内容左右值。 2017-06-15 01:59:25.745 HyperTest [3865:8825385]相关的UICollectionViewFlowLayout实例是,它被连接到; 层=; contentOffset:{0,0}; contentSize:{414,219}>集合视图布局:。 2017-06-15 01:59:25.745 HyperTest [3865:8825385]在UICollectionViewFlowLayoutBreakForInvalidSizes中创build一个符号断点,以便在debugging器中捕获这个断点。 特别是当我这样做: let layout = billFeedCollectionView.collectionViewLayout as? UICollectionViewFlowLayout // casting is required because UICollectionViewLayout doesn't offer header pin. It's feature of UICollectionViewFlowLayout layout?.sectionHeadersPinToVisibleBounds = true layout?.estimatedItemSize = UICollectionViewFlowLayoutAutomaticSize 反正我可以解决这个问题? 我需要确保细胞适应所有设备。

插入新的单元格到UICollectionView

我试图添加一个新的单元格到我的集合视图,只有当它有多个项目已经在它。 我没有收集意见的工作太多,在文档和本网站的研究还没有帮助解决这个问题呢。 所以,在我的cellForItemAtIndexPath方法,我做了检查,看看它是否填充。 如果没有,我添加单元格,如下所示: – (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { if (self.myArray.count != 0) { return self.myArray.count + 1; } else { return self.myArray.count; } } // The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath: – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { MyNormalCollectionViewCellS *cells = (MyNormalCollectionViewCells *) [collectionView dequeueReusableCellWithReuseIdentifier:@"MyNormalCollectionViewCells” forIndexPath:indexPath]; cell.clipsToBounds […]

使用SDWebImageManager在UICollectionView中延迟加载图像

在我的方法cellForItemAtIndexPath我有这样的代码: SDWebImageManager *manager = [SDWebImageManager sharedManager]; [manager downloadWithURL:[NSURL URLWithString:coverURL] options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize) { } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) { RRRBigItemCell *cell = (RRRBigItemCell *)[collectionView cellForItemAtIndexPath:indexPath]; if (cell) { RRRImageView *coverView = (RRRImageView *)[cell viewWithTag:COVER_TAG]; coverView.image = image; } }]; 当我启动应用程序,我向下滚动然后一切都OK。 但是当我滚动比已经显示的单元格没有加载图像(单元格==零)。 如果我再次向下滚动问题仍然是显示单元格,只有新的加载图像。 任何想法我做错了什么?

UICollectionView:如何处理视图加载之前和之后的更新?

在通过KVO接收更新时,我遇到更新集合视图的问题。 例如删除我执行以下操作: dispatch_async(dispatch_get_main_queue(), ^{ NSUInteger index = [self.albumObjects indexOfObject:oldObject]; NSIndexPath* indexPath = [NSIndexPath indexPathForItem:index inSection:0]; [self.dataSource removeObjectAtIndex:index]; [self.collectionView deleteItemsAtIndexPaths:@[indexPath]]; } 以上给我的错误: attempt to delete item 0 from section 0 which only contains 0 items before the update 好的…因此,我们从数据源中删除,然后返回以下错误: dispatch_async(dispatch_get_main_queue(), ^{ NSUInteger index = [self.albumObjects indexOfObject:oldObject]; NSIndexPath* indexPath = [NSIndexPath indexPathForItem:index inSection:0]; [self.collectionView deleteItemsAtIndexPaths:@[indexPath]]; [self.dataSource removeObjectAtIndex:index]; […]

UIScrollView中的UICollectionView – >滚动顺序

我有一个UIScrollView内的UICollectionView 。 我的计划是,如果UICollectionView到达顶部或底部,则外部滚动UICollectionView获取滚动手势。 如果外部ScrollView到达顶部或底部,则CollectionView将获取手势。 我该怎么做?