Hi everyone,
I am trying to create a horizontal UIScrollView with a few images in it. The user should be able to scroll horizontal between all the images. If he holds down the finger the scrolling should stop.
I though about making a
- UIScrollView (320 x 122 px)
- UIView for the content + really big width
- UIImageView for the individual images
Here is my code:
headScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 122)];
[self.view addSubview:headScrollView];
// Dafür einen contentView programmatisch festlegen
headContentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, headScrollView.frame.size.height)];
[headContentView setBackgroundColor:[UIColor lightGrayColor]];
[headScrollView addSubview:headContentView];
[headScrollView setContentSize:headContentView.frame.size];
headImageView = [[UIImageView alloc] init];
NSMutableArray *elements = [appDelegate getElements];
for (int i = 0; i < [elements count]; i++) {
headImageView.image = [UIImage imageNamed:[[elements objectAtIndex:i] nameOfElement]];
[headContentView addSubview:headImageView];
}
But it's not working. There is no image there :-( When I do a NSLOG i get 3 names of the images, so it should work...
Any ideas?
Thanks!