I need to style the default delete button on a tableview cell in objective c, ios5. The general idea is the assumption that you can do something like this:
UIImage *addImage = [UIImage imageNamed:@"greenButtonDark.png"];
UIButton *addButton = [UIButton buttonWithType:UIButtonTypeCustom];
addButton.frame = CGRectMake(0, 0, addImage.size.width, addImage.size.height);
[addButton setImage:addImage forState:UIControlStateNormal];
[addButton addTarget:self action:@selector(pushAddItem) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *addBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:addButton] ;
self.navigationItem.rightBarButtonItem = addBarButtonItem;
The above code is called in the viewDidLoad method and overwrites the right button in the header. I assume there is something comparable for any button the system adds by default but I don't know how to access this particular one.
If I am failing to articulate this, the delete button I refer to is the one automatically generated with this code...
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if(editingStyle == UITableViewCellEditingStyleDelete)
{
//do something when someone hits delete
}
}
If I need to clarify anything let me know. Thanks.