IOS UIButton用法詳解

2021-09-09 02:14:46 字數 771 閱讀 3038

這段**動態的建立了乙個uibutton,並且把相關常用的屬性都列舉了.希望對大家有用.

注意:[button1addtarget:self

action:@selector(alarmtimedone:)

forcontrolevents:uicontroleventtouchupinside

];addtarget:self 是鏈結到self,一般都這樣設定

action:@selector(alarmtimedone:) 時間處理函式

forcontrolevents:uicontroleventtouchupinside 控制項事件處理的訊息

//取消按鈕已經新增的所有事件:(這個比較重要,若新增了兩個事件  兩個事件都會被觸發)

[btn removetarget:nil action:nil forcontrolevents:uicontroleventtouchupinside];

何時釋放release uibutton?

是否在dealloc中對uibutton物件進行release操作,取決於uibutton初始化的方式。

如果使用 [uibuttonbuttonwithtype:uibuttontyperoundedrect]這種方式,是不需要進行release操作的,因為 這種方式是自動釋放的。如果使用 [[uibutton alloc]init]的方式,則需要主動進行release釋放操作。

IOS UIButton用法詳解

這段 動態的建立了乙個uibutton,並且把相關常用的屬性都列舉了.希望對大家有用.注意 button1addtarget self action selector alarmtimedone forcontrolevents uicontroleventtouchupinside addtarg...

IOS UIButton用法詳解

注意 button1addtarget self action selector alarmtimedone forcontrolevents uicontroleventtouchupinside addtarget self 是鏈結到self,一般都這樣設定 action selector al...

IOS UIButton用法詳解

這段 動態的建立了乙個uibutton,並且把相關常用的屬性都列舉了.希望對大家有用.注意 button1addtarget self action selector alarmtimedone forcontrolevents uicontroleventtouchupinside addtarg...