|
@@ -148,6 +148,7 @@ class PQSelecteMusicView: UIView {
|
|
|
let musicIndex = musicDatas.firstIndex(where: { (music) -> Bool in
|
|
|
(music.musicId == model.musicId)
|
|
|
})
|
|
|
+
|
|
|
if(musicIndex == nil){
|
|
|
model.voiceStatue = .isSelected
|
|
|
searchMusiceDatas.insert(model, at: 0)
|
|
@@ -156,17 +157,18 @@ class PQSelecteMusicView: UIView {
|
|
|
musicDatas.insert(model, at: 0)
|
|
|
}
|
|
|
}else{
|
|
|
- musicDatas[musicIndex!].voiceStatue = .isSelected
|
|
|
+
|
|
|
+ let selectMusicData = musicDatas[musicIndex!]
|
|
|
+ selectMusicData.voiceStatue = .isSelected
|
|
|
+ musicDatas.remove(at: musicIndex!)
|
|
|
+ musicDatas.insert(selectMusicData, at: 0)
|
|
|
}
|
|
|
|
|
|
selectMusicCollection.reloadData()
|
|
|
|
|
|
//划动到选择的音乐位置
|
|
|
- if(musicIndex != nil){
|
|
|
- selectMusicCollection.scrollToItem(at: IndexPath(row: musicIndex!, section: 0), at: .centeredHorizontally, animated: true)
|
|
|
- }else{
|
|
|
- selectMusicCollection.scrollToItem(at: IndexPath(row: 0, section: 0), at: .centeredHorizontally, animated: true)
|
|
|
- }
|
|
|
+ selectMusicCollection.scrollToItem(at: IndexPath(row: 0, section: 0), at: .centeredHorizontally, animated: true)
|
|
|
+
|
|
|
}
|
|
|
func autolayout() {
|
|
|
categoryCollection.snp.makeConstraints { make in
|