UIScrollView works as expected but scrollRectToVisible: does nothing

前端 未结 8 2298
一向
一向 2020-12-14 05:46

I have used UIScrollView before, and am using it now, and never had a problem. I\'m now adding it to an old app, and while it works as expected (I can look at

相关标签:
8条回答
  • 2020-12-14 06:14

    I had the same symptoms as this issue..the scrollRectToVisible was not working as intended. My problem was that the scrollview on the storyboard had a ambiguous constraint problem. Once that was fixed the call worked just fine. It is something else to check when the scrollRectToVisible call isn't working as intended.

    0 讨论(0)
  • 2020-12-14 06:16

    i had it like this and it didn't work

    scrollView.contentSize = CGSizeMake(scrollView.contentSize.width, someKnownValue);
    

    i was just changing the height of the contentSize, so I didn't think that would give me any problem but it did ...

    had to change it to this

    scrollView.contentSize = CGSizeMake(someOtherKnownValue, someKnownValue);
    

    turns out scrollView.contentSize.width is not necessarily set to a valid value from the get go, so better give it an specific value

    0 讨论(0)
提交回复
热议问题