Hopefully some one can help me out with this...
I have a table view that has a list of 5 different categories. When I click each category it takes you to a view that has text and images. I am trying to make each view have multiple SCROLLABLE Images, but when I put the code in each view, I have an error in xcode that says duplicate symbol...which I am guessing I can't have the same code in each view? It works in my first view so when that category is clicked from my table the user can scroll thru the text and scroll images. But like I said, the second I add the image scroll code to my next view Duplicate code error! So if I can't have the same code in each view, what can I do so that each of my 5 views allows users to scroll thru multiple images?
Here is the code I am trying to add to each .m:
const CGFloat kScrollObjHeight = 142.0;
const CGFloat kScrollObjWidth = 211.0;
const NSUInteger kNumImages = 2;
- (void)layoutScrollImages
{
UIImageView *view = nil;
NSArray *subviews = [scrollView2 subviews];
CGFloat curXLoc = 0;
for (view in subviews)
{
if ([view isKindOfClass:[UIImageView class]] && view.tag > 0)
{
CGRect frame = view.frame;
frame.origin = CGPointMake(curXLoc, 0);
view.frame = frame;
curXLoc += (kScrollObjWidth);
}
}
[scrollView2 setContentSize:CGSizeMake((kNumImages * kScrollObjWidth), [scrollView2 bounds].size.height)];
}
- (void)viewDidLoad
{
self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor];
[scrollView2 setBackgroundColor:[UIColor clearColor]];
[scrollView2 setCanCancelContentTouches:NO];
scrollView2.indicatorStyle = UIScrollViewIndicatorStyleWhite;
scrollView2.clipsToBounds = NO;
scrollView2.scrollEnabled = YES;
scrollView2.pagingEnabled = YES;
NSUInteger i;
for (i = 1; i <= kNumImages; i++)
{
NSString *imageName = [NSString stringWithFormat:@"jfg%d.png", i];
UIImage *image = [UIImage imageNamed:imageName];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
CGRect rect = imageView.frame;
rect.size.height = kScrollObjHeight;
rect.size.width = kScrollObjWidth;
imageView.frame = rect;
imageView.tag = i;
[scrollView2 addSubview:imageView];
[imageView release];
}
[self layoutScrollImages];
}
Thanks for your help!!

Mandy