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

mathieuhendey

macrumors newbie
Original poster
Dec 27, 2011
8
0
Hi

I'm having a minor problem with my paging UIScrollView. It works correctly, but there is some odd behaviour. Basically, the scrollView contains 7 UIImages with gestureRecognizers. Now, the selectors all fire when I tap the Images, but the scrollView also resets itself so it's back on the first page any time I tap anywhere. I am making the scrollView programatically. Here is how I'm doing that:

Code:
    scrollView = [[UIScrollView alloc] init];
    scrollView.frame = CGRectMake(0,0,316,50);
    scrollView.contentSize = CGSizeMake(460, 50);
    scrollView.pagingEnabled = YES;
Any help would be awesome.
 

ArtOfWarfare

macrumors G3
Nov 26, 2007
9,563
6,062
Your problem occurs when the user taps on the images, not at setup, so wouldn't seeing the code that's executed when a tap is detected be more useful?
 

OverByThere

macrumors newbie
Nov 24, 2011
28
0
Rugby, UK
As ArtOfWarfare has stated, we do need to know the code you use to move between images.

Here is some code I use in a current app to move to another page:
Code:
CGRect nextFrame = myScrollView.frame;
	nextFrame.origin.x = nextFrame.size.width*currentPage;
	[myScrollView scrollRectToVisible:nextFrame animated:YES];

Using the above code, currentPage is a integer containing the page I'm on, so always will return 1,2,3 etc, then multiplying by the frame's width, will tell the scrollview to display that CGRect area.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.