Good day,
my problem is as follows:
I have a scrollview and I add multiple windows to them. Between them is a small empty space. When I scroll the images move but a ‘copy’ of them stays on the background.
If I wouldn’t have the empty spaces between the images you wouldn’t see it, but filling it with a color isn’t the solution because the mainview has a background image that should be visible through the gaps.
Anyone any idea?
code:
lookbookScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0f, 490.0f, 768.0f, 375.0f)];
[lookbookScroll setScrollEnabled:YES];
[lookbookScroll setContentSize:CGSizeMake(([books count] * 275) + 20, 375)];
[self.view addSubview:lookbookScroll];
for (int i = 0; i < [books count]; i++)
{
UIButton *tmpButton = [UIButton buttonWithType:UIButtonTypeCustom];
[tmpButton setFrame:CGRectMake((i * 275) + 20, 0, 265, 375)];
[tmpButton setBackgroundColor:[UIColor blackColor]];
[tmpButton setBackgroundImage:[[books objectAtIndex:i] valueForKey:@"Image"] forState:UIControlStateNormal];
[tmpButton setTag:[[books objectAtIndex:i] valueForKey:@"Id"]];
[tmpButton addTarget:self action:@selector(readBook:) forControlEvents:UIControlEventTouchUpInside];
[lookbookScroll addSubview:tmpButton];
}
adig was right, it was placed in the view did load and it got called twice. Placed it in the init now and that solved the problem. Much thanks for the quick replies.