Group Group Group Group Group Group Group Group Group

UIViewPropertyAnimator Inconsistency

#1

Hello, I was wondering is someone would be able to help me. I’m working on an app where I have to add a button to the screen in code and this button muse move up with the tableView while simultaneously shift over to the right and stop at the navigationBar. The button also decreases its width. I used a UIViewPropertyAnimator to accomplish this.

Now due to how the screen is built, I can’t just add the button to the tableView and let the tableView handle the scrolling of the button when the user scrolls the content. Instead when the user pulls to refresh I move the button inside scrollViewDidScroll by simply changing the value of the button’s frame.origin.y when scrollView.contentOffset.y is smaller then 0. In the same delegate method I use the property animators fractionComplete property to scrub the animation with the scrollView.

My main issue seems to be that when the user abruptly scrolls the tableView up during a pull to fresh, the UIViewPropertyAnimator fires off correctly but the button sometimes stops a few points below the spot where it should stop at the end of the animation, sometimes it stops above that designated spot. Im not sure whats causing this.

Any help would highly appreciated. Thanks!

#2

@may_ber00t Thanks very much for your question. In fairness I can’t really address the reason why you’re having trouble without looking at any code, but my first guess is perhaps it may have something to do with your Auto Layout constraints? Have you used break points to look at what is happening?

Just wondering.

closed #3

This topic was automatically closed after 166 days. New replies are no longer allowed.