Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

Thread: Table View Help
View Single Post
Old 07-05-2009, 01:24 PM   #1 (permalink)
sarahconnor
Support Female Indie-Devs
 
sarahconnor's Avatar
 
Join Date: Apr 2009
Location: Austin
Posts: 197
Exclamation Table View Help

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
sarahconnor is offline   Reply With Quote
 

» Advertisements
» Online Users: 830
24 members and 806 guests
ADY, anshuk1219, cinquiemeas, ckgni, Desert Diva, dfvdan, GFish, GHuebner, iph_s, joeallenpro, john love, keeshux, marcelglaeser, marto1914, nfung, nru, oztemel, RoryHarvey, supasounds, tomtom100, VikMyr, waq963, _Mac
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,868
Threads: 89,225
Posts: 380,692
Top Poster: BrianSlick (7,129)
Welcome to our newest member, stokesreece
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:28 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.