Hi all,
I'm a beginner of iPhone development. I also set 95 pages with (320, 480)pixel in scrollView' content size.
I want to get selected index number when i scroll in UIScrollView.
My code is here;
(void)viewDidLoad { [super viewDidLoad];
NSLog(@"Selected page %d",scrollView.contentOffset.x) ;
scrollView.pagingEnabled = YES;
NSUInteger i;
for (i = 1; i <= kNumImages; i++) {
NSString *imageName = [NSString stringWithFormat:@"page (%d).png", i];
UIImage *image = [UIImage imageNamed:imageName];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
CGRect rect = imageView.frame;
rect.size.height = kScrollObjHeight;
rect.size.width = kScrollObjWidth;
imageView.frame = rect;
imageView.tag = i;
NSLog(@"Selected page %d",scrollView.contentOffset.x) ;
[scrollView addSubview:imageView];
[imageView release];
}
[self layoutScrollImages];
}
Hope Help!