[Solved] Remove uiimage atindex with a button [closed]


I suggest a simpler approach. When you move a view to the front to let the user begin dragging it, save the view to a weak instance variable frontImageView.

When the user taps on the button, invoke code like this:

[frontImageView removeFromSuperview];

Edit:

Note that that approach would let the user remove an image view after they have dragged it, but only once. Once you’ve removed an image view, you’d have to tap another one in order to be able to remove it. If you want to be able to remove the top image view regardless of whether it’s been tapped/dragged or not, you’d need to check your parent view controller’s subviews array.

If the view that contains all your image views is called containerView, the code might look like this:

[containerView.subviews.lastObject removeFromSuperview];

That second line would let the user tap the remove button repeatedly and delete one image after another without having to tap on a new image to select it.

5

solved Remove uiimage atindex with a button [closed]