开发者

Deleting Buttons

I have run-time c开发者_如何学Pythonreated buttons in a View, placed in a grid-looking way. Now I want the user to have the possibility to delete each and every one of them by choosing. How can I identify to one the user have chosen to properly delete it out from View? I use Tag property in the creating process.

Thank you.


here's one way to do it. When making a button, set the action to the view or whichever class is controlling the button pushing logic:

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

then, implement the deleteMe: method somewhere in your class:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜