swift 3 error : Argument labels '(_:)' do not match any available overloads on UICollectionViewLayout (Spinning wheel)
swift 3 error : Argument labels '(_:)' do not match any available overloads on UICollectionViewLayout (Spinning wheel)
我是编程新手,我正在尝试对 CollectionView 制作圆形效果,我有以下内容:
override func prepare()
{
super.prepare()
let centerX = collectionView!.contentOffset.x + (collectionView!.bounds.width / 2.0)
attributesList = (0..<collectionView!.numberOfItems(inSection: 0)).map { (i)
-> CircularLayoutAttributes in
// 1
let attributes = CircularLayoutAttributes(forCellWithIndexPath: IndexPath(forItem: i, inSection: 0))
attributes.size = self.itemSize
// 2
attributes.center = CGPoint(x: centerX, y: self.collectionView!.bounds.midY)
// 3
attributes.angle = self.anglePerItem*CGFloat(i)
return attributes
}
但我收到错误:参数标签“(_:)”与任何可用的重载不匹配,如图所示,我做错了什么?
Swift 3.
语法发生了变化
使用:
IndexPath(item: i, section: 0)
我是编程新手,我正在尝试对 CollectionView 制作圆形效果,我有以下内容:
override func prepare()
{
super.prepare()
let centerX = collectionView!.contentOffset.x + (collectionView!.bounds.width / 2.0)
attributesList = (0..<collectionView!.numberOfItems(inSection: 0)).map { (i)
-> CircularLayoutAttributes in
// 1
let attributes = CircularLayoutAttributes(forCellWithIndexPath: IndexPath(forItem: i, inSection: 0))
attributes.size = self.itemSize
// 2
attributes.center = CGPoint(x: centerX, y: self.collectionView!.bounds.midY)
// 3
attributes.angle = self.anglePerItem*CGFloat(i)
return attributes
}
但我收到错误:参数标签“(_:)”与任何可用的重载不匹配,如图所示,我做错了什么?
Swift 3.
语法发生了变化使用:
IndexPath(item: i, section: 0)