I created a scroll view , but i want to made it to act like a page view .
- (void)setupScrollView:(UIScrollView*)scrMain {
for (int i=1; i<=11; i++) {
image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.png",i]];
if (i==1) {
imgV = [[UIImageView alloc] initWithFrame:CGRectMake(20, 2, 289, 470)];
}
else
imgV = [[UIImageView alloc] initWithFrame:CGRectMake((i-1)*350, 2, 289, 470)];
imgV.contentMode=UIViewContentModeScaleToFill;
[imgV setImage:image];
imgV.tag=i+1;
[imgV bringSubviewToFront:self.aleatoire];
[scrMain addSubview:imgV];
UIImageView *aleatoire=[[UIImageView alloc]initWithFrame:CGRectMake (self.aleatoire.frame.origin.x-19,self.aleatoire.frame.origin.y,self.aleatoire.frame.size.width,self.aleatoire.frame.size.height)];
aleatoire.image=self.aleatoire.image;
[imgV addSubview:aleatoire];
[imgV bringSubviewToFront:aleatoire];
UIButton *rand = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[rand addTarget:self
action:@selector(randomBtn:)
forControlEvents:UIControlEventTouchUpInside];
rand.frame=aleatoire.frame;
rand.backgroundColor=[UIColor clearColor];
rand.userInteractionEnabled = YES;
imgV.userInteractionEnabled=YES;
[imgV addSubview:rand];
[imgV bringSubviewToFront:rand];
}
[scrMain setContentSize:CGSizeMake(scrMain.frame.size.width*11, scrMain.frame.size.height)];
}
the next image is not in the center . Any ideea where i'am wrong ?