What would be the code to delete buttons that was created programmatically for this case for example:
for (m=0; m<f;m++ )
{
numerodeboton=partenumero+m+1;
//NSLog(@"crear boton2, %i", numerodeboton);
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setBackgroundImage:[UIImage imageNamed:@"boton.png"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(notasCurso)forControlEvents:UIControlEventTouchUpInside];
[button setTitle:[NSString stringWithFormat:@"Botón %d", numerodeboton] forState:UIControlStateNormal];
button.frame = CGRectMake(espacioh+m*(h+d)-z + h/2, y + (l-1)*(v+d) + v/2, 1, 1);
button.layer.cornerRadius = 30;
button.clipsToBounds = YES;
button.layer.borderColor=[UIColor blackColor].CGColor;
button.layer.borderWidth=0.01f;
[button setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
button.tag = numerodeboton;
[UIView animateWithDuration:0.05*numerodeboton animations:^{
button.frame = CGRectMake(espacioh+m*(h+d)-z, y + (l-1)*(v+d), h, v);
}];
[self.view addSubview:button];
}
Let’s say that I want to delete the button with tag = 3, what would be the code?
The line
[[self.view viewWithTag:3] removeFromSuperview];would get the button with tag 3 and then remove it. If you have multiple buttons with a tag of 3, just loop through them like so: