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 > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-05-2009, 01:24 PM   #1 (permalink)
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
Old 07-05-2009, 10:07 PM   #2 (permalink)
Support Female Indie-Devs
 
sarahconnor's Avatar
 
Join Date: Apr 2009
Location: Austin
Posts: 197
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



» Advertisements
» Stats
Members: 158,760
Threads: 89,201
Posts: 380,569
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jeeep
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:28 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0