I have a UITableViewController with a method called "sectionOpen". In this controller I have a UITableView with custom headers, which are in fact a UIViewController. I have attached a UITapGestureRecognizer to it, it works if I call a selector on the header's View Controller.
The thing is I need to call a selector on the UITableViewController not the header's View Controller.
Here's my code:
// UITableViewController .m
- (IBAction) sectionOpen:(UITapGestureRecognizer)recognizer {
//Do Something
}
// Header CustomSectio开发者_开发知识库nHeader .h
@interface CustomSectionHeader : UIViewController {
id delegate;
}
@property (nonatomic, retain) id delegate;
//Header CustomSectionHeader .m
@synthesize delegate;
- (id) initWithSection:(NSInteger)section delegate:(id)aDelegate {
if (self = [super init]) {
self.delegate = aDelegate;
[self delegateSetUp];
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(sectionOpen:)];
[self.view addGestureRecognizer:tapGesture];
[tapGesture release];
}
return self;
}
- (void) delegateSetUp {
[self setDelegate:self.delegate];
NSLog(@"DELEGATE: %@", [self delegate]);
}
How do I call sectionOpen on UITableViewController from CustomSectionHeader?
Thanx in advance
Try something like
... initWithTarget:aDelegate ...
I have no idea what "delegateSetUp" is supposed to do; it doesn't seem to do anything.
精彩评论