animated这些方法的参数有什么作用UICollectionView:
selectItem(at indexPath: IndexPath?, animated: Bool, scrollPosition: UICollectionViewScrollPosition)`
Run Code Online (Sandbox Code Playgroud)
deselectItem(at indexPath: IndexPath, animated: Bool)
Run Code Online (Sandbox Code Playgroud)
我知道我可以使用该UICollectionViewLayout对象来为更改设置动画。我也知道我可以使用didSelect和 的didDeselect方法UICollectionViewDelegate来获取选定的单元格并应用动画。但是我找不到有关上述animated参数如何影响动画的任何信息。它会以任何方式影响布局动画吗?我的目标是创建一个UICollectionView子类,并允许消费者自定义在内部调用上述两种方法时是否应用动画。但我不知道这些方法控制什么动画。
我是iOS的Sprite Kit的新手.我想在场景中添加一个形状节点.场景是灰色的,形状是场景中心的白色圆圈.我的场景代码如下.由于某种原因,将节点添加到场景的最后一行导致节点计数增加2.如果我离开那条线,那么就有0个节点,只有灰色场景.但是如果我离开该行,那么圆圈就在那里,但是节点数是2.这是一个很大的问题,因为当我向圆圈添加更多节点时,节点数量应该是它应该是的两倍并且减慢了速度.谁知道问题是什么?非常感激!
@interface ColorWheelScene()
@property BOOL contentCreated;
@end
@implementation ColorWheelScene
- (void)didMoveToView:(SKView *)view {
if(!self.contentCreated) {
[self createSceneContents];
self.contentCreated = YES;
}
}
- (void)createSceneContents {
self.backgroundColor = [SKColor grayColor];
self.scaleMode = SKSceneScaleModeAspectFit;
SKShapeNode *wheel = [[SKShapeNode alloc]init];
UIBezierPath *path = [[UIBezierPath alloc] init];
[path moveToPoint:CGPointMake(0.0, 0.0)];
[path addArcWithCenter:CGPointMake(0.0, 0.0) radius:50.0 startAngle:0.0 endAngle:(M_PI*2.0) clockwise:YES];
wheel.path = path.CGPath;
wheel.fillColor = [SKColor whiteColor];
wheel.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame));
[self addChild:wheel];
}
@end
Run Code Online (Sandbox Code Playgroud) 我有一个水平UICollectionView的几个部分,每个部分包含几个单元格,如下所示:
第 0 部分:取消选择的一个单元格。
第 1 部分:最近选择的项目。
第 2 部分及以后:每个部分都有几个可以选择的项目。
When a cell from section 2 or later is selected, a copy of that item is inserted to the start section 1 in the data source, and I want to reload section 1 to reflect the updated recent items. 但是,我想保留滚动位置。我试过了:
[collectionView reloadSections:setWithIndex1]和
[collectionView reloadItemsAtIndexPaths:arrayWithAllSection1IndexPaths]
我已经尝试使用[collectionView performBatchUpdates:],但是我尝试过的所有操作都使滚动偏移量重置为集合视图的开头。我已经尝试通过使用基本集合视图启动一个新应用程序并使用 重新加载一个部分来进行完整性检查reloadSections,并且它具有不重置滚动偏移的期望行为。但是在我现有的代码库中做同样的事情确实会重置偏移量。
我已经倾注了我的collectionView相关代码来寻找reloadData's、setContentOffsets's 和类似的东西,但对于我的生活,我找不到导致它的原因。有什么我遗漏的东西可以在更新后重置滚动位置吗?