I have a UIScrollView that contains any number of thumbnails that should detect a touch event, perform 3D conversion on their own and call the delegate method.
One problem that I cannot overcome is finding out which sublayer is being used. I set layer.name to the number of indices, and a subclass of UIScrollView receives a touch event. Now the last remaining hurdle is how to do a hitTest on sublayers to get the name and voila property!
I thought of a subclass of UIView as a CALayer container and thus fixed a touch event. But I hope that there may be a more economical way to identify the affected sublayer.
The code I tried (in my subclass of UIScrollView):
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
if ([touches count] == 1) {
for (UITouch *touch in touches) {
CGPoint point = [touch locationInView:[touch view]];
CALayer *alayer = [self.layer hitTest:point];
if (alayer) NSLog(@"layer %@ touched",alayer.name);
else NSLog(@"layer not detected");
}
}
}
. : hitTest . - ".