单击集合视图单元格不工作Swift时振动iPhone

时间:2017-12-24 10:33:37

标签: ios iphone swift

我有一个简单的UICollectionView

的应用程序

我只需要从此collectionView应用中选择任何单元格进行振动

这是我的代码

import AudioToolbox

ManualWaveCollectionView : UICollectionViewDataSource  , UICollectionViewDelegate , UICollectionViewDelegateFlowLayout{
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = self.collectionView.dequeueReusableCell(withReuseIdentifier: "locationsCell", for: indexPath) as! LocationCollectionViewCell
        let location = self.cellLocations[indexPath.row]
        cell.locationName.text = location.location
        return cell
    }

    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return self.cellLocations.count
    }

    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))
        AudioServicesPlaySystemSound(SystemSoundID(kSystemSoundID_Vibrate))   
    }
}

在点击collectionViewCell时,没有任何事情可以保持打印()

iam使用Iphone 5s

1 个答案:

答案 0 :(得分:0)

a