Reputation: 51
I created a five button check this link, How to remove duplicate buttons
i tried this code:
oneBtn1.hidden = YES;
Problem is: I created a buttons with same name but different tag. It is possible to remove button comparing tag or any other way to solve these problem.
Thanks.
Upvotes: 2
Views: 4137
Reputation: 1748
the name you used to create button, only point to the last one button, so, it only remove one button. other buttons as subviews of [self.view], has no var point to.
use
[self.view viewWithTag:theTag]
to get the button with tag, then operate on it.
Upvotes: 1
Reputation: 6445
If you want to remove the button with a particular tag, then use
[(UIButton*)[self.view viewWithTag:TAG_ID] removeFromSuperview];
Upvotes: 7