Tag: uicollectionview

在不同的数组中添加不同部分的选定单元格,UICollectionView

我想在数组中添加UICollectionView选定单元格,不同数组中的部分UICollectionView表示不同的数组。 问题是这个部分是dynamic的。 以下是我的代码。 – (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { NSString *seatV; int cs; NSString *secVal = [arrSeatSel objectAtIndex:indexPath.section]; NSArray *arrSplit = [secVal componentsSeparatedByString:@":"]; seatV = [arrSplit objectAtIndex:1]; cs = [seatV integerValue]; int v; NSString *cnt = [NSString stringWithFormat:@"%@",[arrTot objectAtIndex:indexPath.section]]; v = [cnt intValue]; NSString *sect = [NSString stringWithFormat:@"%d", indexPath.section]; if(indexPath.item < v) { if([sectionInfo count] […]

如何在UICollectionViewCell中使用详细披露button?

我试图使用下面的图片(PhotoSearchViewController)的视图控制器上的详细披露button来显示一个UIAlertController,它显示从ImageUrlItem的照片说明。 当我点击button时,它显示它被按下,但是包含描述的警报没有出现。 我的代码ImageUrlItem: import Foundation import Firebase struct ImageUrlItem { //Should I add my description in here? let key: String let imageUrl: String let watsonCollectionImageUrl: String let score: Double let description: String let ref: FIRDatabaseReference? init(imageUrl: String, key: String = "", watsonCollectionImageUrl: String = "", score: Double = 0, description: String) { self.key = key […]

如何在我的项目中使用SDWebImage

Iam使用collectionview加载图像。这些图像在后台线程中从url加载。 因此,滚动不平滑。在url中的图像过期秒后,因此我想用新的图像更新图像。如何使用SDWebImage加载图像,并使滚动平滑? 任何人都可以请帮我解决这个问题。

UICollectionView水平页面之间的空间分页

我正在寻找一种方法来取代UIPageViewController本地UIPageViewController水平分页。 到目前为止我做了以下几点: let layout = UICollectionViewFlowLayout() layout.scrollDirection = .horizontal layout.itemSize = collectionView.frame.size layout.minimumLineSpacing = 0 layout.minimumInteritemSpacing = 10 collectionView.setCollectionViewLayout(layout, animated: false) collectionView.isPagingEnabled = true collectionView.alwaysBounceVertical = false 这工作正常,我得到一个水平分页效果。 现在我想在页面之间添加水平空间(就像你将UIPageViewControllerOptionInterPageSpacingKey上的UIPageViewController ) 到目前为止,我不能罚款的方式来添加空间而不损坏分页效果。 即时通讯寻找与UIPageViewController相同的行为:单元格应填充整个屏幕宽度,单元格之间的空间应该只在切换页面时可见。

如何正确插入或删除UICollectionView补充视图

简短的问题: 有没有一种方法来添加和删除类似于insertItemsAtIndexPaths: deleteItemsAtIndexPaths:或甚至reloadItemsAtIndexPaths:方法的performBatchUpdates:块中的单元格和部分的补充视图? 长解释: 我使用UICollectionView与部分。 单元格像网格一样布置,每行最多可以有6个单元格。 如果单元的总数不填满某个部分的所有行,我将添加其他补充视图。 额外的补充意见只是填补了空白。 所以结果应该是每个部分完全填充所有可用的单元格,并且(可能的)剩余空白点填充补充视图。 所以每行有6个视觉元素,一个单元格或一个补充视图。 为了实现这一点,我实现了一个自定义的UICollectionViewFlowLayout基于布局与以下prepareLayout:实现: – (void)prepareLayout { [super prepareLayout]; self.supplementaryViewAttributeList = [NSMutableArray array]; if(self.collectionView != nil) { // calculate layout values CGFloat contentWidth = self.collectionViewContentSize.width – self.sectionInset.left – self.sectionInset.right; CGFloat cellSizeWithSpacing = self.itemSize.width + self.minimumInteritemSpacing; NSInteger numberOfItemsPerLine = floor(contentWidth / cellSizeWithSpacing); CGFloat realInterItemSpacing = (contentWidth – (numberOfItemsPerLine * […]

animationUICollectionView标题高度更改

我目前正在使用带有标题的UICollectionView,并且想知道如何在需要时animation和扩展标题高度。 我试图模仿在Expedia的iPhone应用程序中find的function,点击图片展开标题单元格以显示中心的图像: 我一直在尝试这一点,所以任何build议将是伟大的。

UIView遵循UICollectionView指标

我想创build一个包含UIImageView和UILabel的自定义UIView,它指向UICollectionView的滚动指标,并与它滚动。 我正在使用这个代码: – (void)scrollViewDidScroll:(UIScrollView *)scrollView { //get refrence of vertical indicator UIImageView *verticalIndicator = ((UIImageView *)[scrollView.subviews objectAtIndex:(scrollView.subviews.count-1)]); // get the relative position of the indicator in the main window CGPoint p = [verticalIndicator convertPoint:verticalIndicator.bounds.origin toView:[[UIApplication sharedApplication] keyWindow]]; // set the custom view new position CGRect indicatorFrame = self.indicatorView.frame; indicatorFrame.origin.y = py; self.indicatorView.frame = indicatorFrame; } […]

使用自动布局时,设置UICollectionViewFlowLayout的属性不起作用

我试图build立一个UICollectionView与UICollectionViewFlowLayout与以下要求: minimumLineSpacing应该总是正好UICollectionView的高度的三分之一 。 我最初的想法是重写viewDidLayoutSubviews像这样: override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() collectionViewFlowLayout.minimumLineSpacing = collectionView.frame.height / 3 collectionViewFlowLayout.invalidateLayout() } 请注意,我使用viewDidLayoutSubviews,因为我打算使用自动布局,框架可能取决于一些复杂的约束。 所以我不能自己计算框架,但必须等到自动布局计算出来让我在viewDidLayoutSubviews中使用。 我通过编程创build一个UICollectionView来testing这个(并且旋转模拟器来查看minimumLineSpacing是否总是正确的)。 它似乎工作得很好。 然后,我切换到自动布局。 我只是简单地将collections视图的顶部,底部,前后空间限制在其超级视图中。 这样做后,设置minimumLineSpacing不再有预期的效果,它只是没有改变集合视图的外观的任何东西。 以下代码很好地演示了这个问题。 只要我将useAutoLayout设置为true ,设置minimumLineSpacing不再工作。 class DemoViewController: UIViewController, UICollectionViewDataSource { var collectionView: UICollectionView! var collectionViewFlowLayout: UICollectionViewFlowLayout! // MARK: – UIViewController override func viewDidLoad() { super.viewDidLoad() collectionViewFlowLayout = UICollectionViewFlowLayout() collectionViewFlowLayout.itemSize = CGSizeMake(100, 100) collectionView = […]

通过手势交换单元格的位置

我有我有一个原型单元格和UIImageView UICollectionView我在UICollectionView中显示随机图像。 现在我想通过将它移动到附近的单元格来交换UIImageView的位置。我尝试了轻扫手势和长按手势。下面给出了我已经完成的代码: – (IBAction)LongPress:(UILongPressGestureRecognizer *)sender { if (sender.state != UIGestureRecognizerStateEnded) { return; } CGPoint p = [sender locationInView:self.collectionView]; NSIndexPath *indexPath = [self.coll_out indexPathForItemAtPoint:p]; if (indexPath == nil) { NSLog(@"couldn't find index path"); } else { // get the cell at indexPath (the one you long pressed) UICollectionViewCell* cell =[self.coll_out cellForItemAtIndexPath:indexPath]; // do stuff with […]

如何筛选字典和输出结果到Swift的CollectionViewController

我正在制作一个显示口袋妖怪及其types的应用程序。 也是应用程序的一部分将显示其弱点。 我有一个全局variables,列出所有的口袋妖怪,看起来如下: var objects = [ { "id": "001", "typeTwo": "Poison", "name": "Bulbasaur", "type": "Grass" }, { "id": "002", "typeTwo": "Poison", "name": "Ivysaur", "type": "Grass" }, { "id": "025", "typeTwo": "", "name": "Pikachu", "type": "Electric" }] 等等… 当用户从第一个VC中select一个口袋妖怪时,他们按下一个button,它将该口袋妖怪的对象传递给我的CollectionViewController – 并将其存储在var selectedPokemonObject = [String:String]() 我有我的CollectionViewController设置,然后筛选我的宠物小精灵对象,并显示只匹配口袋妖怪,用户selecttypes的口袋妖怪。 例如: 用户select: 皮卡丘 ( "Electric" ) 用户然后去CollectionViewController和types"Electric"所有口袋妖怪被显示。 我的一些代码是: var filteredObjects […]