UIView相關知識

2021-06-09 00:00:12 字數 796 閱讀 7058

1、在mac os中nswindow的父類是nsresponder,而在i os 中uiwindow 的父類是uiview。程式一般只有乙個視窗但是會又很多檢視。

2、uiview的作用:描畫和動畫,檢視負責對其所屬的矩形區域描畫、布局和子檢視管理、事件處理、可以接收觸控事件、事件資訊的載體、等等。

3、uiviewcontroller 負責建立其管理的檢視及在低記憶體的時候將他們從記憶體中移除。還為標準的系統行為進行響應。

4、layoutsubviews 可以在自己定製的檢視中過載這個方法,用來調整子檢視的尺寸和位置。

5、uiview的setneedsdisplay和setneedslayout方法。首先兩個方法都是非同步執行的。而setneedsdisplay會呼叫自動呼叫drawrect方法,這樣可以拿到uigraphicsgetcurrentcontext,就可以畫畫了。而setneedslayout會預設呼叫layoutsubviews,就可以處理子檢視中的一些資料。

宗上所訴,setneedsdisplay方便繪圖,而layoutsubviews方便出來資料

**:6、如果要移除乙個 uiview 的所有子檢視,sdk 裡沒有 remove all 之類的方法。可以用 for loop 迴圈呼叫 – removefromsuperview 來移除

例如:for(uiview *view in [self.view subviews])

複製**

7、如果要移動指定的檢視,可以這樣:

for(uiview *mylabelview in [self.view subviews])}

複製**

UIView的屬性和相關操作

建立window self.window uiwindow alloc initwithframe uisreen mainscreen bounds self.window.backgroundcolor uicolor whitecolor self.window makekeyandvisib...

UIView的一些知識

1.uiview 不能接觸觸控事件的幾種情況 1.userinteractionenabled no 2.hidden yes 3.alpha 0.0 0.01 2.控制項不能接受使用者互動的情況 當控制項的userinteractionenabled no 的時候 透明度小於等於0.01時 uiv...

mysql相關知識 MySQL相關知識

字串拼接 select from tablename where mydata like concat curdate limit 3 這裡concat是字串拼接,concat mys q l mysql 顯示日期不帶時間的函式,如 2015 05 14 curdate 是日期不算時間 2015 0...