
How can i remove any image from an array by clicking? I try it with .remove (at:0) but it didn't work. It removes only in order and my goal is to remove any of them.
ForEach(mediaItems.items,id: \.id) { item in
ZStack{
HStack {
if item.mediaType == .photo {
Image(uiImage:item.photo ?? UIImage())
.resizable()
.frame(width: 112, height: 90)
.cornerRadius(13)
} else if item.mediaType == .video {
if let url = item.url {
VideoPlayer(player: AVPlayer(url: url))
.frame(minHeight: 200)
} else { EmptyView() }
}
}
Image("Tracé 2424")
.offset(x: 40, y: -30)
.onTapGesture{
// mediaItems.items.remove(at:0)
}
}
} //foreach