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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($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 01-28-2012, 09:03 AM   #1 (permalink)
I will be a billionaire.
 
IphoneSdk's Avatar
 
Join Date: Sep 2009
Location: Scarborough, United Kingdom
Age: 17
Posts: 1,344
IphoneSdk is on a distinguished road
Default UITableView Label Addition

I have a UITableView with a Custom label in every cell. I want to be able to add up the total of every cell's label and display it in another label in the toolbar. Any help would be appreciated.

I create the label to be added like this in the cellForRowAtIndexPath:

Code:
Item *i = (Item *) [appDelegate.items objectAtIndex:indexPath.row];

thirdLabel = [[[UILabel alloc] initWithFrame:CGRectMake(246.0, 5.0, 43.0, 55.0)] autorelease];
    thirdLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:25.0];
    thirdLabel.textAlignment = UITextAlignmentCenter;
    thirdLabel.adjustsFontSizeToFitWidth = YES;
    thirdLabel.tag = 4;
    thirdLabel.textColor = [UIColor blackColor];
    thirdLabel.backgroundColor = [UIColor clearColor];
    [cell.contentView addSubview:thirdLabel];
    thirdLabel = (UILabel *)[cell viewWithTag:4];
    thirdLabel.text = [NSString stringWithFormat:@"%i", i.need];
Thanks
__________________
iOS Apps | Website | Twitter | Facebook
IphoneSdk is offline   Reply With Quote
Old 01-28-2012, 11:53 AM   #2 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

So do the math on your Items and show the total. This has nothing to do with labels in the cell.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 01-28-2012, 12:20 PM   #3 (permalink)
I will be a billionaire.
 
IphoneSdk's Avatar
 
Join Date: Sep 2009
Location: Scarborough, United Kingdom
Age: 17
Posts: 1,344
IphoneSdk is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
So do the math on your Items and show the total. This has nothing to do with labels in the cell.
How do you add objects in arrays?
__________________
iOS Apps | Website | Twitter | Facebook
IphoneSdk is offline   Reply With Quote
Old 01-28-2012, 12:36 PM   #4 (permalink)
Registered Member
 
apatsufas's Avatar
 
Join Date: Jan 2011
Location: Thessaloniki, Greece
Posts: 121
apatsufas is on a distinguished road
Default

Loop through every Item in your array and add up the total

Code:
int total = 0;
for (Item* i in appDelegate.items) {
total += i.theItemsPropertyYouWant
}
__________________
SQLed - Your Database Manager on the go

iAZConverter - Converts everything from A to Z
apatsufas is offline   Reply With Quote
Old 01-28-2012, 01:07 PM   #5 (permalink)
I will be a billionaire.
 
IphoneSdk's Avatar
 
Join Date: Sep 2009
Location: Scarborough, United Kingdom
Age: 17
Posts: 1,344
IphoneSdk is on a distinguished road
Default

Quote:
Originally Posted by apatsufas View Post
Loop through every Item in your array and add up the total

Code:
int total = 0;
for (Item* i in appDelegate.items) {
total += i.theItemsPropertyYouWant
}
Thanks a lot! Works perfectly!
__________________
iOS Apps | Website | Twitter | Facebook
IphoneSdk 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
» Online Users: 402
11 members and 391 guests
Atatator, condor304, FrankWeller, imac74, MAMN84, mraalex, n00b, PowerGoofy, QuantumDoja, tim0504, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,674
Threads: 94,123
Posts: 402,908
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Atatator
Powered by vBadvanced CMPS v3.1.0

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