ios - iOS7.1 - can't change center of view using UIPanGestureRecognizer and AutoLayout -
i have view want move around using uipangesturerecognizer
. view placed within uicollectionviewcell
subclass. i'm using autolayout
layout view. constraints looks this:
[self.contentview addsubview:self.containerview]; [self.contentview addconstraints:[nslayoutconstraint constraintswithvisualformat:@"h:[_containerview(==290)]" options:nslayoutformatdirectionleadingtotrailing metrics:nil views:nsdictionaryofvariablebindings(_containerview)]]; [self.contentview addconstraints:[nslayoutconstraint constraintswithvisualformat:@"v:|-(15)-[_containerview]" options:nslayoutformatdirectionleadingtotrailing metrics:nil views:nsdictionaryofvariablebindings(_containerview)]]; self.containerviewheightconstraint = [nslayoutconstraint constraintwithitem:self.containerview attribute:nslayoutattributeheight relatedby:nslayoutrelationequal toitem:nil attribute:nslayoutattributenotanattribute multiplier:1 constant:350]; self.containerviewrightconstraint = [nslayoutconstraint constraintwithitem:self.containerview attribute:nslayoutattributetrailing relatedby:nslayoutrelationequal toitem:self.contentview attribute:nslayoutattributetrailing multiplier:1 constant:15]; [self.contentview addconstraints:@[self.containerviewheightconstraint, self.containerviewrightconstraint]];
it containerview
want move around using uipangesturerecognizer
. in cellforitematindexpath
add together recogniser view: [cell.containerview addgesturerecognizer:self.resultpanrecognizer];
.
the relevant part of selector resultpanrecognizer (uipangesturerecognizer
) looks this:
// should reposition view, works in ios8.1, not ios7. cgpoint translation = [recognizer translationinview:self.collectionview]; recognizer.view.center = cgpointmake(recognizer.view.center.x + translation.x, recognizer.view.center.y + translation.y); [recognizer settranslation:cgpointmake(0, 0) inview:self.collectionview];
so, code works in ios 8, in ios7.1 view resets it's position it's original position user starts panning.
my theories have been, inconsistent behaviour of uicollectionviews (specifically content views) between ios7 , 8, or autolayout constraints
causing view reset on ios7.
but haven't found workaround worked.
any suggestions?
ios objective-c uicollectionview autolayout uipangesturerecognizer
No comments:
Post a Comment