简体   繁体   中英

How to remove Button from View

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.

如果要删除带有特定标记的按钮,请使用

[(UIButton*)[self.view viewWithTag:TAG_ID]  removeFromSuperview];

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM