the visual design of my custom table view doesn't accommodate apple's built-in delete editing style. therefore, i'm attempting to create my own delete function.
within the custom cell's nib, i've created a custom delete UIButton that will become visible when the user enters my app's table view delete mod. the image of the delete button is 22x22, but the actual button has a greater size to make touching easier. the first thing i've noticed is that these buttons are very difficult to press. if i make the button larger, the cells seem to get confused (pressing the delete button on the first cell activates the delete on the 2nd cell). interestingly, this seems to only occur if my custom delete button is located at the very right edge of my custom cell. move it to the right appears to solve the issue. moving on.
from my custom cell class, i've added an IBOutlet to the tableView's delegate and an IBAction for the delete button, and wired up the connection in IB:
so now in my tableViewDelegate class, my deleteTableViewCell method currently looks like this:
first problem: the deleteTableViewCell method is not receiving the message from the custom cell class. I'm assuming this is due to an error on my part, and i'm hoping it's not because my custom cell's XIB bypasses the use File's Owner as it's just a subclass of UITableViewCell. if this is the case, i hope there is a simple solution.
because my connections aren't working, i can't test the affectiveness of my deleteTableViewCell
NSIndexPath *)indexPath method. in this method i'm removing the objects at index path, both from the table view and the data source. i'm not sure if i'm also to update the tableView/data source in this method, or if it's automatic, but that should be easy enough to figure out.
so. why is my table view delegate class not receiving the message from my UITableViewCell subclass, and does my deleteTableViewCell
NSIndexPath *)indexPath appear to be correct?
within the custom cell's nib, i've created a custom delete UIButton that will become visible when the user enters my app's table view delete mod. the image of the delete button is 22x22, but the actual button has a greater size to make touching easier. the first thing i've noticed is that these buttons are very difficult to press. if i make the button larger, the cells seem to get confused (pressing the delete button on the first cell activates the delete on the 2nd cell). interestingly, this seems to only occur if my custom delete button is located at the very right edge of my custom cell. move it to the right appears to solve the issue. moving on.
from my custom cell class, i've added an IBOutlet to the tableView's delegate and an IBAction for the delete button, and wired up the connection in IB:
Code:
#import <UIKit/UIKit.h>
@class TableViewDelegate;
@interface CustomCell : UITableViewCell
{
TableViewDelegate *tableViewDelegateClass;
UILabel *label1;
UILabel *label2;
UIButton *deleteButton;
}
@property (nonatomic, retain) IBOutlet UILabel * label1;
@property (nonatomic, retain) IBOutlet UILabel * label2;
@property (nonatomic, retain) IBOutlet UIButton *deleteButton;
- (IBAction)deleteButton:(id)sender atIndexPath:(NSIndexPath *)indexPath;
@end
#import "CustomCell.h"
#import "TableViewDelegate.h"
@implementation SizeMeMeasurementsCell
@synthesize label1, label2, deleteButton;
- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier
{
if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier])
{
// Initialization code
}
return self;
}
- (IBAction)deleteButton:(id)sender atIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"Action Triggered");
[tableViewDelegateClass deleteTableViewCell:indexPath];
}
- (void)dealloc
{
[label1 release];
[label2 release];
[deleteButton release];
[super dealloc];
}
@end
so now in my tableViewDelegate class, my deleteTableViewCell method currently looks like this:
Code:
- (void)deleteTableViewCell:(NSIndexPath *)indexPath
{
NSLog(@"Message Received From Custom Cell");
NSUInteger row = [indexPath row];
[self.listDataArray removeObjectAtIndex:row];
[self.myTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
first problem: the deleteTableViewCell method is not receiving the message from the custom cell class. I'm assuming this is due to an error on my part, and i'm hoping it's not because my custom cell's XIB bypasses the use File's Owner as it's just a subclass of UITableViewCell. if this is the case, i hope there is a simple solution.
because my connections aren't working, i can't test the affectiveness of my deleteTableViewCell
so. why is my table view delegate class not receiving the message from my UITableViewCell subclass, and does my deleteTableViewCell