Tag: uicollectionview

UICollectionView – 一次一个Cell的水平分页

我试图用collectionView来实现一个类似于效果的旋转木马。 我实现了UICollectionView并将其设置为水平显示单元格。 唯一的问题是我怎样才能允许一个单元格的外观,并将该单元格居中在屏幕上。 注意:寻呼已启用。 我发现这个代码,试了一下,但可悲的是没有工作 代码参考: 用Swift创build一个分页UICollectionView override func targetContentOffsetForProposedContentOffset(proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint { if let cv = self.collectionView { let cvBounds = cv.bounds let halfWidth = cvBounds.size.width * 0.5; let proposedContentOffsetCenterX = proposedContentOffset.x + halfWidth; if let attributesForVisibleCells = self.layoutAttributesForElementsInRect(cvBounds) { var candidateAttributes : UICollectionViewLayoutAttributes? for attributes in attributesForVisibleCells { // […]

UICollectionView – 滚动到下一页

有没有机会使用UICollectionView滚动到想要的项目。 scrollToItemAtIndexPath并且不是捕捉到物品本身,而是捕捉物品所属的页面? (我启用了分页function。) 干杯

configurationUICollectionViewFlowLayout从底部到顶部布置行

默认情况下(即垂直滚动方向),UICollectionViewFlowLayout从左上angular开始,从左到右,直到行被填充,然后进入下一行。 相反,我希望它从左到右,从左到右,直到行被填充,然后继续下一个行。 有没有一个简单的方法来做到这一点,通过inheritanceUIScrollViewFlowLayout,或者我基本上需要从头重新实现该类? 苹果关于子类stream布局的文档表明,我只需要重写和重新实现我自己版本的layoutAttributesForElementsInRect: , layoutAttributesForItemAtIndexPath:和collectionViewContentSize 。 但这似乎并不简单。 由于UICollectionViewFlowLayout不公开任何网格布局计算,它在prepareLayout进行内部prepareLayout ,所以我需要从它为顶部到底部布局生成的值推导出底部到顶部布局所需的所有布局值。 我不确定这是可能的。 虽然我可以重新使用它的计算关于哪些组项目被放在同一行,我将需要计算新的y偏移量。 为了使我的计算,我将需要有关所有项目的信息,但这些超类方法不报告。

自动调整UICollectionView标题

我正在尝试做一个待办事项列表类应用程序的详细屏幕。 以下是详细信息屏幕当前的样子: 这是一个带有标题的UICollectionViewController 。 标题包含2个UILabel对象和一个UITextView对象。 这些对象的布局由一个垂直的UIStackView来pipe理。 UIView用于设置白色背景。 我在运行时定义这个UICollectionReusableView的高度有一些困难。 任何意见表示赞赏。

初始化一个自定义的UICollectionViewCell

我有一个自定义的UICollectionViewCell有一个自定义的背景视图,使用几种配色scheme之一绘制。 背景视图的颜色scheme是在我的自定义初始化程序-(id)initWithFrame:andColourPalette:设置的视图。 我在我的UICustomViewCell子类中有一个类似的自定义初始化,但我不知道如何调用这个初始化,当我在cellForItemAtIndexPath:设置单元格cellForItemAtIndexPath: 任何人都可以帮我做到这一点? 或者提供另一种解决scheme,将这个Dictionary的颜色传递给Cell传递给子视图? 编辑显示更多的细节: 这是我在我的UICollectionView VC: 在ViewWillAppear中: [self.collectionView registerClass:[OPOLawCollectionViewCell class] forCellWithReuseIdentifier:CELL_ID]; self.colourPalette = [OPOColourPalette greenyColourPalette]; 在cellForItemAtIndexPath中: UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CELL_ID forIndexPath:indexPath]; OPOLawCollectionViewCell *lawCell = (OPOLawCollectionViewCell *)cell; MainLevel *level = self.collectionData[indexPath.row]; lawCell.delegate = self; lawCell.colourPalette = self.colourPalette; 在我的自定义UICollectionViewCell中 – (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // get background view OPOLawBook […]

UICollectionElementKindCell带有标识符的视图不能出队

我有UICollectionView,但似乎我设置一切正确。 但是我得到的错误: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier PeopleCellForList – must register a nib or a class for the identifier or connect a prototype cell in a storyboard' 我的故事: 我的代码是: @interface PeopleCellForList : UICollectionViewCell @end @implementation PeopleCellForList @end #pragma mark – UICollectionView Datasource – (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section { return self.arrayPeople.count; } […]

添加更多单元格UICollectionView

那么现在我正在从Instagram取代我的图片到屏幕的底部,而不是添加新的单元格。 我将如何添加新的单元格而不是replace以前的单元格? 这是我的完整实现文件来检索图像的下一页: @interface StreamViewController () <UITextFieldDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout> @property (nonatomic, strong) NSMutableDictionary *timelineResponse; @property (nonatomic, strong) CredentialStore *credentialStore; @property (weak, nonatomic) IBOutlet UICollectionView *collectionView; @end @implementation StreamViewController – (void)viewDidLoad { [super viewDidLoad]; [self refreshInstagram]; //Refresh UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init]; [refreshControl addTarget:self action:@selector(startRefresh:) forControlEvents:UIControlEventValueChanged]; [self.collectionView addSubview:refreshControl]; //Instigate Navigation Bar Buttons UIButton *barButton = […]

是否有可能作为一个单位缩放UICollectionView?

我们最近的项目中有一个关卡地图视图。 它包括水平标记作为UICollectionViewCells和各种UICollectionReusableViews乐趣装饰。 我们希望能够放大/缩小(这是一个大的地图)。 我曾希望我可以使用内部的UIScrollView来做到这一点,但是,你不能放大自己…只有一个子视图。 无论如何,要做到这一点,除了单独缩放和重新放置每个元素,因为我缩放? 感觉它应该是一个普通的东西,因此是一个更“内置”的解决scheme。

重新排列部分之间的项目时,UICollectionView崩溃

我在UICollectionView部分之间有animation变化的麻烦,我的程序不断崩溃,有什么问题呢? 我有一个收集视图,它有四个部分: 0:A 1:B 2:C 3:D 我想把它变成只有三个部分具有相同的项目: 0:A 1:B,C 2:D 而且我想要让这个转变成为animation: // Initial state NSArray *source = @[ @[@"A"], @[@"B"], @[@"C"], @[@"D"] ]; // Some data source methods – (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return [source[section] count]; } – (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return [source count]; } // Transformation: that works but I have to keep an […]

通过UICollectionView单元快速枚举 – Swift

我想通过所有的收集视图单元快速枚举,但是下面的这个实现给我一个警告。 for cell in self.collectionView?.visibleCells() as [UICollectionViewCell] { // Do Stuff } 下面的错误出现在第一行: postfix'?'的操作数 应该有可选的types; types是'(UICollectionView,cellForItemAtIndexPath:NSIndexPath) – > UICollectionViewCell' 我已经尝试了可选项,并在Xcode 6 Beta 6中工作,但无济于事的“Beta 7” 我如何摆脱这个错误? /编写一个循环遍历所有我的CollectionView单元格?