For some reason, I can’t seem to remove a UIImageView without removing all of my UIButtons as well. All subviews were added to my main view _ourView and UIButtons were not given a tag (default 0) and my image was given a tag=5.
When I call
NSInteger o = [obj intValue]; //This is the letter "O" not 0, and o = 5 in this case (which is what my subview tag is)
UIView *hangmanView = [_ourView viewWithTag:o];
[hangmanView removeFromSuperview];
[_ourView setNeedsDisplay];
All of my buttons also disappear.
Any pointers?
EDIT: I have uploaded my project to github if you want to see more code. Here is the link to the file: https://github.com/elayman/Hangman/blob/master/Hangman/HangmanViewController.m#L172
0 is the default for tag… so it takes the first view without a tag and that’s probably not what you want.
Log what you remove so you can see what actually happens: