简体   繁体   中英

Animation does not Work as Expected While Resizing UIView

In our question module I need to resize and animate UIView when user clicked answers which are represented by tableview. I have read some related questions and applied their solution but none of them worked for me.

The problem is uiview doesn't appear at first click but if user click same answers 2 times or more it appears because in second click on same answers does not change the frame.

so basically if the feedback of answer change, height of the uiview gonna be recalculated and I guess it is blocking animation.

my view hierarchy: http://i.imgur.com/Oho6Hob.png

method which changes the constraints of views and textview:

self.feedbackLabelWrapperHeight.constant = height + 45;
self.feedbackViewHeight.constant = height + 45 + 12;
int y = height;

[self.feedbackView setFrame:CGRectMake(50,self.scrollView.frame.size.height + self.scrollView.frame.origin.y -(y+40),self.feedbackView.frame.size.width,(y+40))];

animation method:

[UIView beginAnimations:@"feedback" context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.2];
[UIView setAnimationDelay:delay];
[self.view layoutIfNeeded];
[UIView commitAnimations];
self.isFeedbackViewVisiable = YES;

I'm calling these two methods in didSelectRowAtIndexPath method in these order: and labelHeightOfResponse parameter is the calculated height of related label or textview

[self setFeedbackConstraintHeight:labelHeightOfResponse];
[self feedbackViewAppearAnimationWithDelay:0.2 yPosition:labelHeightOfResponse];

I would really appreciate help here. Thanks!

after spending a week I've added a constraint which does nothing. I don't know why but it solved animation blocking furthermore it worked perfectly even I deleted layoutIfNeeded.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM