问题描述
我已经在一组卡片中提供了我的所有专辑详细信息,我想将数组传递给当前专辑变量并在 .onAppear 中打印 id 或名称
struct MyModel: Codable{
var currentAlbum = [0]
struct Album : Identifiable {
var id : Int
var album: String
var image: String
}
}
class Myviewmodel: ObservableObject {
func getCurrent(){
let getCurrentCard = CardsData[0].id
let getCurrentAlbum = MyModel.currentAlbum[0]
let getBoth = (getCurrentCard == getCurrentAlbum)
print(getBoth)
}
}
我想在用户打开相册时打印这个
Button(action: myviewmodel.play
){
Image(systemName: myviewmodel.isPlaying ? "pause.fill" : "play.fill")
.resizable()
.aspectRatio(contentMode: .fit)
.clipShape(Circle())
}.onAppear(perform: {
myviewmodel.getCurrent()
})
所有这些卡片都在循环中
ForEach(CardsData) { item in
vstack {
ContentButtonsView(Cards: item)
.matchedGeometryEffect(id: item.id,in: namespace,isSource: !show)
.onTapGesture {
withAnimation(.spring(response: 0.7,dampingFraction: 0.8,blendDuration: 0)){
show.toggle()
selectedItem = item
isdisabled = true
}
}
.disabled(isdisabled)
}
.matchedGeometryEffect(id: "container\(item.id)",isSource: !show)
}
请指导我解决这个问题
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)