I’ve got a NavCtrl and on top of that I have a TableView/ctrl, then I have a scrollview.
I’ve got everything working, except I can’t seem to get touches to hit the Cell’s on the table view.
I’ve tried the nextResponder things and everything seems to be doing the right thing. Here’s some snippets of code, keep in mind this code has been changed a lot for testing so it isn’t “clean” yet :):
ScrollView *myScrollView = [[ScrollView alloc] initWithFrame:CGRectMake(0, 150, 320, 680)];
myScrollView.contentSize = CGSizeMake( 320 , 888);
myScrollView.pagingEnabled = NO;
myScrollView.bounces = NO;
myScrollView.directionalLockEnabled = YES;
myScrollView.canCancelContentTouches = NO;
myScrollView.delaysContentTouches = NO;
myScrollView.scrollEnabled = true;
myScrollView.userInteractionEnabled = YES;
myScrollView.scrollsToTop = NO;
mySettingsTableView = [[SettingsTableView alloc] init];
// Settings View Ctrl
SettingsTableViewCtrl *mySettingsTableViewCtrl = [[SettingsTableViewCtrl alloc] initWithStyle:UITableViewStyleGrouped];
mySettingsTableViewCtrl.tableView.scrollEnabled = NO;
mySettingsTableViewCtrl.tableView.delaysContentTouches = NO;
mySettingsTableViewCtrl.tableView.canCancelContentTouches = NO;
mySettingsTableViewCtrl.view.userInteractionEnabled = YES;
[mySettingsTableViewCtrl.view addSubview:myScrollView];
[mySettingsTableViewCtrl.view addSubview:mySettingsTableView];
* In subclass of scrollView *
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
//if (![self yourMethodThatDeterminesInterestingTouches:touches withEvent:event])
[super touchesBegan:touches withEvent:event];
[self.nextResponder touchesBegan:touches withEvent:event];
}
Here’s the NSLog from the touch events:
NSLog(@"Event: %@", event);
NSLog(@"Event NextResponder : %@\n", self.nextResponder);
2011-07-05 13:09:36.063 App[1924:14f03] Event: <UITouchesEvent: 0x802ea30> timestamp: 8503.71 touches: {(
<UITouch: 0x80e6f60> phase: Began tap count: 1 window: <UIWindow: 0x836eb00; frame = (0 0; 320 480); layer = <CALayer: 0x836ebb0>> view: <ScrollView: 0x83770b0; baseClass = UIScrollView; frame = (0 150; 320 680); clipsToBounds = YES; layer = <CALayer: 0x8376e00>; contentOffset: {0, 0}> location in window: {140, 249} previous location in window: {140, 249} location in view: {140, 35} previous location in view: {140, 35}
)}
2011-07-05 13:09:36.065 App[1924:14f03] Event NextResponder : <SettingsTableViewCtrl: 0x8377db0>
Here’s what I ended up, not perfect yet but working, any tuning advice would be much appreciated……
//AppDelegate.m
//ScrollView.m
}
//SettingsTableView.m
Now I have a DatePicker on top of the scrollview and its working but this code needs some additional code to manage it, i.e. detect when picker is “touched” and when its not there. But that shouldn’t be too difficult (I think 😉
Thanks for help and comments,
D