I have some codes to create dynamic button as below:
- (void)viewDidLoad {
for (int i = 0; i < 9; i++)
for (int j = 0; j < 8; j++) {
forControlEvents:UIControlEventTouchDown];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(10+i*34 , 130+j*30, 30 , 20 );
[button setTitle:@"00" forState: UIControlStateNormal];
[button addTarget:self action:@selector(tapped:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
button.tag = i;
}
}
I hope to delete the dynamic uibuttons and recreate them.
How can I do
Welcome any comment.
Thanks
interdev
This removes the button
To remove the series of button:
You have a bit of a minor problem because your inner loop (the one using the j counter) is creating 8 buttons but they all have the same tag. Change how you assign the tag counter and adjust the loop above to use that counter and you should be able to remove all the buttons.