开发者

UIScrollView isn't scrolling to correct location

I have a UIScrollView with several objects in it which, when selected, I'd like them to come to the centre of the view. I am using the following code to do this.

CGRect frameToScrollTo;
frameToScrollTo.origin.x = (centerOfLabel - 150);
frameToScrollTo.origin.y = 0;
frameToScro开发者_JAVA百科llTo.size.width = 300;
frameToScrollTo.size.height = 44;

[self.monthsScroller scrollRectToVisible:frameToScrollTo animated:YES];

I have done tests to make sure the CGRect I'm creating is correct, but the UIScrollView always scrolls leaving part of the rectangle off screen. This only happens when I have content insets applied. My content insets change depending on the content so I can't do anything to remove these.

Can anyone please suggest a fix for this?

Thanks in advance. Ricky.


Sorted it out. I substituted -scrollRectToVisible:animated: with -setContentOffset:animated:.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜