IOS系列——判斷視圖是否存在

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

返回其標記匹配指定值的視圖。
此方法搜索當前視圖及其所有子視圖指定的視圖。
發佈了59 篇原創文章 · 獲贊 3 · 訪問量 12萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章