Hi in my app i want to show label text different at each image in UIScrollView. Here is my code.
for (int i=0; i<imageArray.count; i++)
{
NSString *str = [imageArray objectAtIndex:i];
NSString *bannerImageURL = [NSString stringWithFormat:@"http://url.com", str];
CGFloat myOrigin = i * self.view.frame.size.width;
UIImageView *myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(myOrigin, 0, self.view.frame.size.width,imgScrollView.frame.size.height)];
myImageView.contentMode = UIViewContentModeScaleToFill;
myImageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:bannerImageURL]]];
imgScrollView.contentSize = CGSizeMake(self.view.frame.size.width * imageArray.count, self.view.frame.size.height);
CGPoint scrollPoint = CGPointMake(0, 0);
[imgScrollView setContentOffset:scrollPoint animated:YES];
imgScrollView.delegate = self;
[imgScrollView addSubview:myImageView];
}
Here is my Delegate Methods.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
[imgScrollView setContentOffset: CGPointMake(imgScrollView.contentOffset.x,0)];
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
CGFloat pageWidth = scrollView.frame.size.width;
int page = floor((scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
NSLog(@"Scrolling - You are now on page %i",page);
}
I want to pass an array to that label and one more thing how to add page controller to this code? Please Help.