{"id":69,"date":"2010-06-07T16:36:28","date_gmt":"2010-06-08T00:36:28","guid":{"rendered":"http:\/\/bynomial.com\/blog\/?p=69"},"modified":"2010-06-07T16:36:28","modified_gmt":"2010-06-08T00:36:28","slug":"uiscrollview-bug","status":"publish","type":"post","link":"http:\/\/bynomial.com\/blog\/?p=69","title":{"rendered":"UIScrollView bug"},"content":{"rendered":"<p>This post describes a bug in UIScrollView that occurs when you programmatically set the contentOffset with animation.  Below is code to reproduce the bug; I&#8217;ve confirmed it&#8217;s in iPhone OS 3.2 but it may be in other versions as well.<\/p>\n<p>If you make a call to<\/p>\n<pre>[scrollView setContentOffset:offset1 animated:YES];<\/pre>\n<p>and later make a call to<\/p>\n<pre>scrollView.contentOffset = offset2;<\/pre>\n<p>before the animation is done, the scroll view will <em>not<\/em> end up at offset2, but rather somewhere else that seems to depend on the original position, offset1, and the timing of the calls.<\/p>\n<p>I don&#8217;t have a good workaround for this bug.  For now I&#8217;m just not animating my programmatic scrolls.<\/p>\n<p>Here&#8217;s a screenshot from the reproduction of the bug:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-71\" title=\"UIScrollView_bug_screenshot\" src=\"http:\/\/bynomial.com\/blog\/wp-content\/uploads\/2010\/06\/UIScrollView_bug_screenshot1.png\" alt=\"\" width=\"528\" height=\"682\" srcset=\"http:\/\/bynomial.com\/blog\/wp-content\/uploads\/2010\/06\/UIScrollView_bug_screenshot1.png 528w, http:\/\/bynomial.com\/blog\/wp-content\/uploads\/2010\/06\/UIScrollView_bug_screenshot1-232x300.png 232w\" sizes=\"(max-width: 528px) 100vw, 528px\" \/><\/p>\n<p>Because of the last contentOffset setting, I would expect to see the top of the scroll content (a green bar) in the scroll area, instead of the bottom, which is what we do see.<\/p>\n<p><a href=\"http:\/\/bynomial.com\/blogfiles\/ScrollViewBug.zip\">Here is a one-class xcode project to reproduce the bug.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post describes a bug in UIScrollView that occurs when you programmatically set the contentOffset with animation. Below is code to reproduce the bug; I&#8217;ve confirmed it&#8217;s in iPhone OS 3.2 but it may be in other versions as well. If you make a call to [scrollView setContentOffset:offset1 animated:YES]; and later make a call to [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[59,11,15],"tags":[61,60],"_links":{"self":[{"href":"http:\/\/bynomial.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/69"}],"collection":[{"href":"http:\/\/bynomial.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bynomial.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bynomial.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/bynomial.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=69"}],"version-history":[{"count":0,"href":"http:\/\/bynomial.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/69\/revisions"}],"wp:attachment":[{"href":"http:\/\/bynomial.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=69"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bynomial.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=69"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bynomial.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=69"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}