UIScrollView works as expected but scrollRectToVisible: does nothing
Yeah, I have not had success with scrollRectToVisible:animated:
, but setContentOffset:animated:
always works for me. Out of curiosity, why do you not want to use setContentOffset:animated:
? It seems to be the proper solution.
Over a month later, and I finally figured it out. While the alternative above worked well, it has been bugging me and I had to finally figure it out. Turns out that it was somewhat of a stupid mistake.
Here's the old code in my viewDidLoad, where I set up the scrollView:
[clefScrollView setContentSize:CGSizeMake(clefScrollView.contentSize.width, clefView.frame.size.height)];
The value of a scrollView height or width can't be 0! I think this got past me because I was assuming that ScrollView sizes start out with a valid size, and I was missing the fact that one dimension was zero!
This works:
[clefScrollView setContentSize:CGSizeMake(clefView.frame.size.width, clefView.frame.size.height)];
Hope this helps someone out there. I definitely spent way too much time trying to debug this.