UIcollectionView.VisibleCell()。count方法返回0,尽管单元格在模拟器中是可见的

时间:2016-06-17 00:42:25

标签: ios swift

func prepareVisibleCellsForAnimation() {

        print("\(self.peopleCollectionView.visibleCells().count)")

//THIS ALWAYS RETURNS 0 ALTHOUGH THE CELLS ARE CLEARY VISIBLE IN THE SIMULATOR

        for i in 0..<self.peopleCollectionView!.visibleCells().count {

            let cell: PeopleViewCell =  self.peopleCollectionView.cellForItemAtIndexPath(NSIndexPath(forItem: i, inSection: 0)) as! PeopleViewCell

            cell.frame = CGRectMake(-CGRectGetWidth(cell.bounds), cell.frame.origin.y, CGRectGetWidth(cell.bounds), CGRectGetHeight(cell.bounds))

            cell.alpha = 0.0


        }

    }

0 个答案:

没有答案