UIScrollView works as expected but scrollRectToVisible: does nothing

前端 未结 8 2336
一向
一向 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: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

提交回复
热议问题