2009-10-13 241 views
0

我有一個視圖中的運行時創建按鈕,放置在一個網格的方式。現在我希望用戶有可能通過選擇刪除它們中的每一個。我如何識別用戶已選擇將其從View中正確刪除的用戶?我在創建過程中使用了Tag屬性。刪除按鈕

謝謝。

回答

1

這裏有一種方法可以做到這一點。製作按鈕時,取其類控制按鈕按下邏輯設定的動作視圖或:

UIButton *theButton = [UIButton buttonWithType:(UIButtonType)]; 
[theButton addTarget:self action:@selector(deleteMe:) forControlEvents:(UIControlEvents)]; 

然後,實施DELETEME:方法某處類:

-(void)deleteMe:(id)sender 
{ 
    //remove the button. sender is the button that was pushed. 
}