I have created a custom UITableViewCell that is added as a subview to my view. In this view there is also a a UITableView. The custom UITableViewCell is not part(included) into the UITableView.
I have set the custom UITableViewCell up in my viewDidLoad method like this.
- (void)viewDidLoad
{
[super viewDidLoad];
// Create custom tableviewCell at top of screen under navigation controller
cellContainer = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 44.0)];
cellContainer.backgroundColor = [UIColor whiteColor];
UITableViewCell *mycell = [[UITableViewCell alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 50.0)];
mycell.textLabel.text = @"Select all";
mycell.backgroundColor = [UIColor whiteColor];
[cellContainer addSubview:mycell];
[self.view insertSubview:cellContainer atIndex:1];
// Set table positioning
[subModelTableView setFrame:CGRectMake(0, 44, self.view.frame.size.width, self.view.frame.size.height - 44)];
[self.view insertSubview:subModelTableView atIndex:0];
// set tableview datasource and delegate
[subModelTableView setDelegate:self];
[subModelTableView setDataSource:self];
}
The thing being at the moment I am unable to select this custom tableview cell, I have tried to set a selector on it like this
[mycell addTarget:self action:@selector(myAwesomeMethod:) forControlEvents:UIControlEventTouchUpInside];
but I am getting an error
No visible @interface for 'UITableViewCell' declares the selector 'addTarget:action:forControlEvents:'
So I would like to know if there is either another way of doing this (proper way) or if I am on the right track how can I resolve this error?
EDIT:
The reason I have this extra UITableViewCell in this view is that it sits below the UINavigationBar as a static cell with @”Select all” in it, this cell sits above the UITableView but gives the appeance of being included in the UITableView but obviously is not.
When the user scrolls the UITableView of values if the user dose not know which cell he would like to select I want to enable the @”Select all” cell, so he receives a list of values that would represent selecting every cell in the UITableView. I hope this makes sense.
I don’t think this is the correct way to do it. I think you should use the UITableViewDelegate’s didSelectRowAtIndexPath method. If this isn’t going to work, then please elaborate on what you’re trying to do so a better suggestion can be provided.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewDelegate_Protocol/Reference/Reference.html