Hello everyone I got weired bug which I can't solve - I dig over the internet and couldn't find any solution. I got a viewcontroller screen with 6 buttons on it. I want to show the user a UIAlertview with a description text any time when clicks on one of those buttons. The problem is that in the first button I got the text right but the problem begins from the second button and so on. The new UIAlertview shows the new description text together with the old text so the new text can't be read.
From the debuger I found that the old UIAlertview are there but just not shown on the main screen.
What is the right way to remove it from the view controller?
This is my dismiss function:
@objc func dismissAlert() {
guard let targetView = mytargetView else {
return
}
UIView.animate(withDuration: 0.25, animations: {self.alertView.frame = CGRect(x: 40, y: targetView.frame.size.height, width: targetView.frame.size.width-80, height: 300)}, completion: {done in
if done {
UIView.animate(withDuration: 0.25, animations: {
self.backgroundView.alpha = 0
}, completion: { done in
if done {
self.alertView.removeFromSuperview()
self.backgroundView.removeFromSuperview()
}
})
}
})
}

The
dismissAlertmethod is not the proper way to dismiss an alert view. You can simply call thedismissmethod on any alert view to properly dismiss it.