我需要知道UICollectionView标头补充视图当前是否在视图中,以便在更改应用程序设置/首选项时强制它刷新/更新.
如果标题不在视图中,一旦滚动到,标题将被适当地绘制,但是现在只在加载时发生,如果用户滚动标题然后返回.
如果标题在视图中,我需要它来更新,但我真的不想每次这个设置改变时重新加载整个第0部分(只是当标题在视图中时...).
objective-c ios uicollectionview uicollectionviewlayout uicollectionreusableview
我使用自定义UICollectionView布局有不同大小的单元格,我无法在此部分.
UICollectionView在同一个地方使用多个s 是个好主意UIViewController吗?有什么建议吗?
这个帖子(也许是愚蠢的)经过连续8个小时对我的计算机像一些愚蠢的猴子一样g ,,因为UICollectionView在iOS 7上存在问题.
我有子类UICollectionViewFlowLayout为我的UICollectionView dataSource的所有50个部分提供了一个通用的"Section X"(Sticky Header)[其中X是一个数字]标题,这是一个NSArray分区.
我- (NSArray *) layoutAttributesForElementsInRect:(CGRect)rect {在我的子类中调用,它确实显示了标题,但仅适用于第一部分.这是非常奇怪的行为.我的期望是:
|S| [CELL] [CELL] |S| [CELL] [CELL]
|E| [ ] [ ] |E| [ ] [ ]
|C| [____] [____] |C| [____] [____]
|T| |T|
| | [CELL] [CELL] | | [CELL]
| | [ ] [ ] | | [ ]
|1| [____] [____] |2| [____]
Run Code Online (Sandbox Code Playgroud)
"SECT 2"是第一个之后的下一个标题,当用户水平滚动时(应用于垂直方向)应该在屏幕上可见,但我得到的是:
|S| [CELL] [CELL] | | [CELL] [CELL]
|E| [ …Run Code Online (Sandbox Code Playgroud) objective-c ios uicollectionview uicollectionviewlayout ios7
我有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'
Run Code Online (Sandbox Code Playgroud)
我的故事:



我的代码是:
@interface PeopleCellForList : UICollectionViewCell
@end
@implementation PeopleCellForList
@end
#pragma mark - UICollectionView Datasource
- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section {
return self.arrayPeople.count;
}
- (NSInteger)numberOfSectionsInCollectionView: (UICollectionView *)collectionView {
return 1;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"PeopleCellForList " forIndexPath:indexPath];
return cell;
}
#pragma …Run Code Online (Sandbox Code Playgroud) ios uicollectionview uicollectionviewcell uicollectionviewlayout
我想创建一个如下所示的UICollectionView:

它不可滚动或可编辑.我目前想知道如何为此编写布局.我猜它不会是一个子类UICollectionViewFlowLayout.我可以想到很多方法,但如果有任何"正确"的方式,我很好奇.细胞将具有动画效果.
每行或每列应该是它自己的部分吗?
有什么区别
collectionViewController.collectionViewLayout.collectionViewContentSize()和collectionViewController.collectionView.contentSize?
你更喜欢用什么?
ios uicollectionview uicollectionviewcell uicollectionviewlayout swift
我收到警告"这可能是因为流布局子类MyApp.MenuFlowLayout正在修改UICollectionViewFlowLayout返回的属性而不复制它们".我如何在Swift中复制它?
override func layoutAttributesForElementsInRect(rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
if let array = super.layoutAttributesForElementsInRect(rect) as [UICollectionViewLayoutAttributes]? {
var visibleRect = CGRectZero
visibleRect.origin = (self.collectionView?.contentOffset)!
visibleRect.size = (self.collectionView?.bounds.size)!
let activeDisatance : CGFloat = visibleRect.size.width / 2
let zoomFactor : CGFloat = 0.15
for attributes in array{
if CGRectIntersectsRect(attributes.frame, visibleRect){
let distance = CGRectGetMidX(visibleRect) - attributes.center.x
let normalizedDistance = distance / activeDisatance
if abs(distance) < activeDisatance{
let zoom = 1 + zoomFactor * (1 - abs(normalizedDistance))
attributes.transform3D = CATransform3DMakeScale(zoom, zoom, 1.0)
attributes.zIndex = …Run Code Online (Sandbox Code Playgroud) insetForSectionAtIndex(在DelegateFlowLayout上)使您可以为节中的所有单元格设置插入
sectionInset(在FlowLayout上)使您可以设置适用于所有部分的插图。
但是,我正在寻找一种仅将插页应用于一个特定部分的方法-这可能吗?
ios uicollectionview uicollectionviewlayout uicollectionviewdelegate swift
是否可以从集合视图 - iOS 9中从一个部分拖动并重新排序到另一个部分.
每次从第1部分拖到第4部分下降到下面崩溃,
断言失败 - [UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:
func collectionView(collectionView: UICollectionView, moveItemAtIndexPath sourceIndexPath: NSIndexPath,toIndexPath destinationIndexPath: NSIndexPath)
{
let sequence = ArrayrelatedSequence[sourceIndexPath.section] as! SEQ_Sequence
relIndexCards = sequence.rel_indexCard
if relIndexCards.count > 0 {
ArrayIndexcard = []
let arr1: NSMutableArray = []
for item in relIndexCards {
arr1.addObject(item)
}
let descriptor: NSSortDescriptor = NSSortDescriptor(key: "keyP_IndexCard_ID", ascending: false)
let arrNew:NSArray = arr1.sortedArrayUsingDescriptors([descriptor])
let i = 0
for item in arrNew
{
ArrayIndexcard.insert(item as! NSManagedObject, atIndex: i)
i+1
}
}
let temp = self.ArrayIndexcard.removeAtIndex(sourceIndexPath.item) …Run Code Online (Sandbox Code Playgroud) 使用以下配置:
let layout = UICollectionViewFlowLayout()
layout.sectionHeadersPinToVisibleBounds = true
let collectionViewController = UICollectionViewController(view.bounds, collectionViewLayout: layout)
Run Code Online (Sandbox Code Playgroud)
以下代码将滚动到给定的索引路径,但该项目将在其标题的下面并被其标题覆盖:
let indexPath = IndexPath(section: 0, row: 2)
collecitonView.scrollToItem(at: indexPath, at: .top, animated: true)
Run Code Online (Sandbox Code Playgroud)
将sectionHeadersPinToVisibleBounds设置为true时,如何使集合视图滚动到indexPath处的项目,而其项没有被其节头覆盖?
uicollectionview uicollectionviewcell uicollectionviewlayout swift