I am currently trying to create a sort of tasktracker.. The following code works currently, but I need it to delete the row with the tag of the button.. In other words.
When button with tag:0 is pressed, delete row with tag:0
All my atempts have failed so I’m bringing it to the experts.
- (void)buttonPressedAction:(id)sender
{
UIButton *button = (UIButton *)sender;
NSInteger *row = button.tag;
NSString *cleanedUp = [NSString stringWithFormat:@"%d", row];
if(button.titleLabel.text == @"Unchecked"){
[button setTitle:@"Checked" forState:UIControlStateNormal];
}
else{
[button setTitle:@"Unchecked" forState:UIControlStateNormal];
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:button.titleLabel.text
message:cleanedUp
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
UITableViewhas built-in capabilities to allow the deletion of rows. This may be better suited for what it sounds like you are trying to accomplish. Here is an example.To use custom buttons you will need use
beginUpdatesandendUpdatesto modify your table view animated.