2015-09-29 20 views
5

さて、iOSメッセージアプリと同様にスクロールしながら、春のようなアニメーションをサポートするUICollectionViewFlowLayoutを用意しました。とにかく、Swift 2.0に変換すると、UIDynamicsが完全に変更されたようです。私は次のブロックを変換しようとしていますが、私はそれを理解していないようで、Appleのドキュメントはここでは非常に支持的ではありません。次のブロックは、まだ変換する必要があります。そして、iOS 9/Swift 2.0のUIDynamicsの問題

"Value of type 'UIDynamicBehavior' has no member 'items' "

私が持っている:

var noLongerVisibleBehaviors = self.dynamicAnimator.behaviors.filter({behavior in 
     var currentlyVisible = itemsIndexPathsInVisibleRectSet.member(behavior.items![0].indexPath) != nil 
     return !currentlyVisible 
    }) 

    for (index, obj) in noLongerVisibleBehaviors.enumerate() { 
     self.dynamicAnimator.removeBehavior(obj) 
     self.visibleIndexPathsSet.removeObject(obj.items![0].indexPath) 
    } 

は、これらのブロックの両方がエラーを引き起こす

:エラーが発生し

override func layoutAttributesForElementsInRect(rect: CGRect) -> [UICollectionViewLayoutAttributes]? { 
     return self.dynamicAnimator.itemsInRect(rect) 
    } 

どのように私はこれを変換できますか?私は迅速2が非常に新しいことを知っていますが、私はこれに関して何もオンラインで見つけることができません。そして、私が言ったように、UIKitDynamicBehaviorのドキュメンテーションは、ほとんど言わないことがありません。あなたの助けを前もってありがとう!

Value of type ' UIDynamicBehavior ' has no member 'items'

let attachmentBehavior:UIAttachmentBehavior = behavior as! UIAttachmentBehavior 

第二の問題解決するには:

答えて

4

最初のブロックの問題解決するには

Cannot convert return expression of type ' [UIDynamicItem] ' to return type ' [UICollectionViewLayoutAttributes]? '

return self.dynamicAnimator.itemsInRect(rect) as? [UICollectionViewLayoutAttributes] 
0

これまでに私を得たが、今は「の値を取得タイプ 'UIDynamicItem'にはメンバー 'indexPath'がありません

私はdd this this

let item = attachmentBehavior.items[0] as! UICollectionViewLayoutAttributes