gpt4 book ai didi

ios - 表达式类型不明确 | SpringyCollectionViewFlowLayout

转载 作者:行者123 更新时间:2023-11-29 12:00:58 25 4
gpt4 key购买 nike

如本 UICollectionViewFlowlayout 中所述, 第 1 步:

// Need to overflow our actual visible rect slightly to avoid flickering.
var visibleRect = CGRectInset(self.collectionView!.bounds, -100, -100)
var itemsInVisibleRectArray: NSArray = super.layoutAttributesForElementsInRect(visibleRect)!
var itemsIndexPathsInVisibleRectSet: NSSet = NSSet(array: itemsInVisibleRectArray.valueForKey("indexPath") as [AnyObject])

// Step 1: Remove any behaviours that are no longer visible.
var noLongerVisibleBehaviours = (self.dynamicAnimator.behaviors as NSArray).filteredArrayUsingPredicate(NSPredicate(block: {behaviour, bindings in
var currentlyVisible: Bool = itemsIndexPathsInVisibleRectSet.member((behaviour as UIAttachmentBehavior).items.first!.indexPath) != nil
return !currentlyVisible
}))

“没有更多上下文,表达类型不明确”..我该怎么办?我真的卡住了:/

感谢您在这方面给我的任何帮助...

最佳答案

如果有人可能只想解决这个问题,请看这里:

    let visibleRect = CGRectInset(self.collectionView!.bounds, -100, -100)
let itemsInVisibleRect = super.layoutAttributesForElementsInRect(visibleRect)!
let indexPathsInVisibleRect = Set(itemsInVisibleRect.map({ (attribute) -> NSIndexPath in
return attribute.indexPath
}))

// Step 1: Remove any behaviours that are no longer visible.

let noLongerVisisbleBehaviors = self.dynamicAnimator.behaviors.filter { (eachBehavior) -> Bool in
var currentlyVisible = false
if let behavior = eachBehavior as? UIAttachmentBehavior, first = behavior.items.first as? UICollectionViewLayoutAttributes {
currentlyVisible = indexPathsInVisibleRect.contains(first.indexPath)
}
return !currentlyVisible
}

值得庆幸的是,这已被证明是当天真正的巨大节省:

关于ios - 表达式类型不明确 | SpringyCollectionViewFlowLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37020411/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com