IOS系列——判断视图是否存在

来源:互联网 发布:mz什么意思网络用语 编辑:程序博客网 时间:2024/05/21 15:39

if( [selfviewWithTag:789] ){                                      //如果tag789的视图存在

        [[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等等 

返回其标记匹配指定值的视图。
此方法搜索当前视图及其所有子视图指定的视图。

原创粉丝点击