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:59 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 Set UITableView Label to UIPickerView Row Text

I have a UITableView with a Custom label in every cell. The label displays an amount of money. The UIPickerView has a load of different currency symbols in it's array. I want to be able to display the selected currency symbol from the pickerView in the custom label in the tableview on every cell. Any ideas on how I could achieve this?

This is my picker view code:

Code:
- (void)viewDidLoad {
    [super viewDidLoad];
    
    list = [[NSMutableArray alloc] init];
[list addObject:@"£"];
[list addObject:@"$"];
    
}

-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
    return 1;
}

-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
    return[list count];
}

-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
    return[list objectAtIndex:row];
}

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {

    currency = [NSString stringWithFormat:@"%@",[list objectAtIndex:row]];
    NSLog(@"Currency: %@", currency);
}
This is how I create the label in the cellForRow...

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

secondLabel = [[[UILabel alloc] initWithFrame:CGRectMake(145.0, 37.0, 96.0, 20.0)] autorelease];
    secondLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:14.0];
    secondLabel.textAlignment = UITextAlignmentLeft;
    secondLabel.adjustsFontSizeToFitWidth = YES;
    secondLabel.tag = 3;
    secondLabel.textColor = [UIColor darkGrayColor];
    secondLabel.backgroundColor = [UIColor clearColor];
    [cell.contentView addSubview:secondLabel];
    secondLabel = (UILabel *)[cell viewWithTag:3];
    secondLabel.text = [NSString stringWithFormat:@"(%@ each )", i.notes];
Thanks for your help.
__________________
iOS Apps | Website | Twitter | Facebook
IphoneSdk is offline   Reply With Quote
Old 01-28-2012, 11:09 AM   #2 (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

EDIT: Problem Solved!!

All I had to do was add
Code:
[self.tableView reloadData];
to the
Code:
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
method and it works!
__________________
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: 401
11 members and 390 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