In the tableView:cellForRowAtIndexPath: implementation of my UITableViewController subclass I'm using this code snippet:
AlarmPicker *alarmPicker = [[AlarmPicker alloc] init];
alarmPicker.scrollViewDelegate = alarmPicker;
[cell.contentView addSubview:alarmPicker.view];
AlarmPicker implements various UIScrollViewDelegate methods.
In AlarmPicker.h I'm declaring scrollViewDelegate as follows:
@property (assign) id<UIScrollViewDelegate> scrollViewDelegate;
This is then being used in the implementation part of AlarmPicker:
UIScrollView *returnScrollView = [[UIScrollView alloc] init];
...
returnScrollView.delegate = self.scrollViewDelegate;
Unfortunately scrollViewDelegate is always null in this AlarmPicker instance so the implemented delegate methods don't get called at all.
A workaround would be to put the UIScrollViewDelegate method implementations into the class which does the alloc and init:
...
alarmPicker.scrollViewDelegate = self;
...
But that would be a very bad solution.
What do I have to do in order to tell the AlarmPicker instance that it should use itself as its delegate?