Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

UITableView Subclass

I have a big problem here. I wrote a custom UITableViewCell subclass completely customized with images and labels. I also created a custom action to edit the UITableView. When tapping the button, I am trying to perform an action to a UIButton which would, when tapped delete the cell. What I have works fine if I have one cell there. Here is what I have for the button to edit the table view.

// UINavigatinBarButton
- (void)editItems:(UIButton *)button {
if (!isEditing) {
NSLog(@\"Editing...\");
isEditing = YES;

[UIView beginAnimations:@\"editButtonFlipContext\" context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:cell.checkmarkImage cache:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.3];
cell.checkmarkImage.image = [UIImage imageNamed:@\"data_cell_delete_button.png\"];
[UIView commitAnimations];

[cell.checkmarkButton addTarget:self action:@selector(deleteCell:event:) forControlEvents:UIControlEventTouchUpInside];

} else {
NSLog(@\"Done Editing.\");
isEditing = NO;

[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(deleteCell:event:) object:nil];

[UIView beginAnimations:@\"editButtonFlipContext\" context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:cell.checkmarkImage cache:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.3];
cell.checkmarkImage.image = [UIImage imageNamed:@\"data_cell_detail_button.png\"];
[UIView commitAnimations];
}
}


and for the UIButton in the cell:

// Cell Button
- (void)deleteCell:(id)sender event:(id)event {
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint currentTouchPosition = [touch locationInView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint: currentTouchPosition];
if (indexPath != nil)
{
NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];
[context deleteObject:[self.fetchedResultsController objectAtIndexPath:indexPath]];
}
}


It all seems to work fine on one cell like I said above, it won't make all the cells have that same action all the time, nor will it set the the correct image to it ("data_cell_delete_button.png"). If you need more info let me know. If you have any suggestions on fixing up the code for both actions I'd greatly appreciate it.

Thanks

Edit 2:
When clicking done on the navigation bar button, it doesn't remove the current @selector for the cell.checkmarkButton
Post edited by Tapbits on

Replies

Sign In or Register to comment.