Xcode- UICollectionView应该选择vs didSelect

时间:2015-03-31 09:23:34

标签: ios xcode swift uicollectionview

    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

        if let selectedItem = collectionView?.indexPathForCell(sender as UICollectionViewCell) {

        if segue.identifier == "next" {

            var second: SecondViewController = segue.destinationViewController as SecondViewController
            second.itemNumber = selectedItem.row

        }
        }
    }

 override func collectionView(collectionView: UICollectionView, shouldSelectItemAtIndexPath indexPath: NSIndexPath) -> Bool {

        if let cell = collectionView.cellForItemAtIndexPath(indexPath) {
            performSegueWithIdentifier("next", sender: cell)
        } 
        return true
    }

    override func collectionView(collectionView: UICollectionView, didDeselectItemAtIndexPath indexPath: NSIndexPath) {


    }

函数shouldSelectItemAtIndexPath完全按照didDeselectItemAtIndexPath的方式运行。 didDeselectItemAtIndexPath以某种单元格而不是随机方式运行。那么这里的问题是什么?

编辑:这是一个错字,我使用didDeselectItemAtIndexPath而不是didSelectItemAtIndexPath

0 个答案:

没有答案