Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

hotkarl

macrumors newbie
Original poster
Nov 19, 2010
29
1
Northern Utah
Howdy, I've tried a few things here and can't find a solution. The problem is that the previous image will show through in the background if it was longer than the new image. Here's my code. Any help would be appreciated.
Code:
-(IBAction) selectLick:(id)sender {
	NSString *titleForButton = [sender titleForState: UIControlStateNormal];
	NSString *imagePath = [[NSString alloc] initWithFormat:@"%@.png", titleForButton];
	NSString *musicPath = [[NSString alloc] initWithFormat:@"%@.mp3", titleForButton];
	UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imagePath]];
	
	[scrollView setBackgroundColor:[UIColor blackColor]];
    [scrollView setCanCancelContentTouches:NO];
    scrollView.clipsToBounds = YES; 
    scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
	[scrollView addSubview:imageView];
    [scrollView setContentSize:CGSizeMake(imageView.frame.size.width, imageView.frame.size.height)];
    [scrollView setScrollEnabled:YES];
	[imagePath release];
	[musicPath release];
    [imageView release];
	
	//[sender setTitleColor:[UIColor colorWithRed:100/255 green:100/255 blue:100/255 alpha:1.0] forState: UIControlStateNormal];
}
 
remove subViews first

Maybe you need try this...

scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
[[scrollView subviews] makeObjectsPerformSelector:mad:selector(removeFromSuperview)]; <<<--- add this line
[scrollView addSubview:imageView];

i'm hope this helps...
 
Thank you so much! That works great. I would not have found that solution for a long time as I am just getting in to this. I sincerely appreciate the response. I have so many questions, but I try to work through them on my own first.

Thanks again!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.