Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

arnieterm

macrumors regular
Original poster
Aug 28, 2008
201
0
Hi All,
I have a UIScrollView that contains a series of UIView in its content view. The scrollview builds as desired and scrolls well with its content size set as needed. I cannot use PagingEnabled==YES due to design restrictions. At any given time the scrollview shows five UIView. When user scrolls enough [== scrollview's bounds] then another 5 UIView appears.
My problem is that I need to place the third UIView [in the currently visible 5 UIView] in the centre of the scrollView so that 2 UIView appears on its left and 2 on its right.
Though I have frame of 3rd UIView and when I pass it to

Code:
scrollRectToVisible
method, that UIView becomes visible but not exactly in the centre.
How can I make it to appear in the centre?

Thanks
Arnieterm
 
Thanks for the suggestion. I am already making use of that function. The problem is that the UIView that I needs to bring in the center position is already visible, so I think using the function
Code:
- (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated
does not work
 
The post at the below given link resembles my problem

http://stackoverflow.com/questions/1677085/paging-uiscrollview-in-increments-smaller-than-content-size

But still than I am not able to understand the calculation done there. Luckily I have also icons of width 50 and height 70 but how to modify that calculation to fit in my case.

Thanks
Arnieterm

Given code is for 50px width icons scrolled horizontally, so since your icons are the same width, you should be able to reuse that code without modifications. Anyway, if you have horizontal margins you should count all "area of interest" replacing 50 with "icon width + margins" value and 25 with a half of that value.

That code checks if to which icon it should "clip" and then scrolls to its center point. And also prevents from scrolling too far.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.