Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

Graves Robber
($1.99)

African Adventure
($0.99)

iTazer
($0.99)

ArtStudio
($3.99)

Pigs Vs Wolves
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-05-2009, 01:24 PM   #1 (permalink)
Self-Taught Code Monkey
iPhone Dev SDK Supporter
 
sarahconnor's Avatar
 
Join Date: Apr 2009
Location: Austin
Posts: 160
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
Old 07-05-2009, 10:07 PM   #2 (permalink)
Self-Taught Code Monkey
iPhone Dev SDK Supporter
 
sarahconnor's Avatar
 
Join Date: Apr 2009
Location: Austin
Posts: 160
Talking Figured it out!

Instead of the const...I needed to define the kscrollHeight, Width and numbers at the top of each .m file! GOT IT!
sarahconnor is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 23,539
Threads: 38,286
Posts: 168,254
Top Poster: smasher (2,533)
Welcome to our newest member, emusher
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:49 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0