if( [selfviewWithTag:789] ){ //如果tag为789的视图存在
[[selfviewWithTag:789]removeFromSuperview];
}
具体有待研究
官方对 viewWithTag 的解释是这样的
Returns the view whose tag matches the specified value. | |
This method searches the current view and all of its subviews for the specified view. |
在这里也顺便说一下,每个视图都可以设置tag 不仅仅包括Button 还有 view imageview等等
返回其标记匹配指定值的视图。
此方法搜索当前视图及其所有子视图指定的视图。