iphone - remove all UIButton's from subview -
I'm adding a couple UIButtons programmatically to my view after clicking on a button, they all have 'removeFromSuperView' or Must be released, not just one
for (int p = 0; p [array number]; p ++) {button = [[UIButton alloc] initWithFrame: CGRectMake (100,100,44,44)] ; Button.tag = p; [Button setbackground image: [UIImage imageNamed: @ "image.png"] forState: UIControlStateNormal]; [Self.view addSubview: button]; [Button addTarget: Self-Proceeding: @Selector (Action :) Control Events: UI ControlAnchart Inside]; }
Now this is the part where all the buttons should be deleted. Not just a
- (zero) verb: (id) sender {UIButton * button = (UIButton *) sender; Int pressed = button. Tag; [Delete the button amperspaveview]; }
I hope someone can help me!
In a more efficient manner, when you create it, each button must be added to the array, and then when If the button is pressed, then call the -removeFromSuperView
method to all the array buttons in this way:
[arrayObtons are created on the object: Filters: @Selector (deleted sender view )]; After that, you can either place the button in the array and reuse them, or by calling removeAllObjects
to release them. You can. You can then populate it again later. This saves you in search of buttons to run through the entire scene hierarchy.
Comments
Post a Comment