开发者

Positioning UIScrollView

I have an iphone app where i display a series of images. When the user taps an image i need to bring that image to the first position,indicating it is the selected image. I am able to achieve the tap in uiscrollview by means of subclassing.But I am not able to position the imageview to the first in uiscrollview. Please help out开发者_如何学C of this problem. Thanks in advance.


You can move the scroll view to a desired position using contentOffset property. You can calculate the image position using the touch position. For example, if the images are scrolled horizontally,

float _x = touchedX - (touchedX % imageViewWidth);
CGPoint contentOffset = CGPointMake(_x, 0); // to scroll horizontally
[scrollView setContentOffset:contentOffset animated:YES];


if u know the position of the imageview in the scrollview, then u can make it to show in the view with the help of setContentOffset:animated: in UIScrollView.

Hope this would help you.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜