Hi
I'm trying to have hitTest detect touches in a UITableView. Currently the didSelect method fails to react to numerous touches I want to ensure that every touch is detected especially as there are quite a few touches required before another view controller is pushed.I'm a total newbie to objective-C but I did manage to find a code snippet someone had kindly provided to the community. I've had to try and adapt it but the app builds then crashes, if anyone can see what I'm doing wrong I would really appreciate the help.
-(UIView*) hitTest:(CGPoint)point withEvent:(UIEvent*)event
{
// check to see if the hit is in this table view
if ([self pointInside:point withEvent:event]) {
UITableViewCell* newCell = nil;
UITableViewCell* activeCell = nil;
// hit is in this table view, find out
// which cell it is in (if any)
for (aCell in self.visibleCells) {
if ([aCell pointInside:[self convertPoint:point toView:aCell] withEvent:nil]) {
newCell = aCell;
break;
}
}
// if it touched a different cell, tell the previous cell to resign
// this gives it a chance to hide the keyboard or date picker or whatever
if (newCell != activeCell) {
[activeCell resignFirstResponder];
activeCell = newCell; // may be nil
}
}
// return the super's hitTest result
return [super hitTest:point withEvent:event];
}
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event {
if ([aCell pointInside:[self convertPoint:point toView:aCell] withEvent:nil]){
return YES;
}
else {
return NO;
}
}
-(CGPoint)convertPoint:(CGPoint)point toView:(UIView *)view
{
return point;
}
I have no idea really whether either -(CGPoint)convertPoint: or - (BOOL)pointInside: have even been done correctly (obvioulsy the app might build even if these methods do nothing). visbleCells is an array of customView table cells.
I also have no idea how to call on the hitTest method. I've done this:
[self sethitTest:bookTable];
Where bookTable is the actual subclassed TableView in the TableViewController.