2009-10-13 160 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. 
}