I have a ViewController with a SubViewView ScrollView, and this subview has a subview in it, below is a hierarchy:
AppDelegate - MyViewController - ScrollView (from xib) - MyScrollViewSubClass
// MyViewController: //.h
@interface MyViewController : UIViewController<MyScrollViewSubClassDelegate,UIScrollViewDelegate> {
UIScrollView *scrollView;
}
@property(nonatomic,retain) IBOutlet UIScrollView *scrollView;
@end
//.m
@implementation MyViewController
@synthesize scrollView;
- (void)viewDidLoad {
[super viewDidLoad];
scrollView.delegate = self;
MyScrollViewSubClass *myScrollView = [[MapScrollView alloc] init];
myScrollView.delegate = self;
myScrollView.myDelegate = self;
scrollView addSubview:mapScrollView];
}
- (void) onDoubleTapLocation: (CGPoint)tapPoint
{
}
// MyScrollViewSubClass + Delegate //.h
@protocol MyScrollViewSubClasswDelegate <NSObject>
@required
- (void) onDoubleTapLocation: (CGPoint)tapPoint;
@end
@protocol MyScrollViewSubClass;
@interface MyScrollViewSubClass : UIScrollView <UIScrollViewDelegate> {
id <MyScrollViewSubClasswDelegate> myDelegate;
}
@property (nonatomic,assign) id<MyScrollViewSubClasswDelegate> myDelegate;
- (void)handleDoubleTap;
@end
//.m
@implementation MyScrollViewSubClass
@synthesize myDelegate;
- (id)initWithFrame:(CGRect)frame
{
if ((self = [super initWithFrame:frame])) {
self.delegate = self;
self.myDelegate = self;
}
return self;
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
if(isDoubleTap)
{
[self handleDoubleTap];
}
}
- (void)handleDoubleTap {
[self.myDelegate onDoubleTapLocation: tapLocation];
}
What happened with double-clicking works on MyViewController, but now I can’t scroll and pinch the scale of my MyScrollViewSubClass from MyViewController, any critics, comments or the best method are welcome.
It is decided:
I assign a delegate to MyViewController twice
:
myScrollView.delegate = self;
myScrollView.myDelegate = self;
Must be:
myScrollView.myDelegate = self;
Yours faithfully,
Ferry Hattavidian