iphone - Multiple pan gestures in a mixing console app -
i ipad mixing console app able move multiple sliders simultaneously when user touches them multiple fingers, in real life.
i have implemented logic single pan gesture (uipangesturerecognizer). how add multiple-touch functionality in case?
there requirement of ios 5.1 compatibility.
edit: reference, here gesture looks on real-life mixing consoles:
you can create separate gesture recognizers each slider, e.g. assuming had collection outlet:
- (void)viewdidload { [super viewdidload]; [self.sliders enumerateobjectsusingblock:^(uiview *slider, nsuinteger idx, bool *stop) { uipangesturerecognizer *pan = [[uipangesturerecognizer alloc] initwithtarget:self action:@selector(handlepan:)]; [slider addgesturerecognizer:pan]; }]; }
then, gesture recognizer handle each 1 individually (surprisingly, without needing recognize them simultaneously shouldrecognizesimultaneouslywithgesturerecognizer
):
- (void)handlepan:(uipangesturerecognizer *)gesture { cgpoint translation = [gesture translationinview:gesture.view]; gesture.view.transform = cgaffinetransformmaketranslation(0.0, translation.y); if (gesture.state == uigesturerecognizerstateended) { cgrect frame = gesture.view.frame; frame.origin.y += translation.y; gesture.view.frame = frame; gesture.view.transform = cgaffinetransformidentity; } }
Comments
Post a Comment