Why is my multi-component UIPickerView crashing? - iphone

I'm trying to create a simple pickerview with two components, drawing its label data from a small mutablearray and output data from a simple matrix. The purpose of this wheel is to select a value from 0 to 1000, and then spit out the number in a label and the value to the rest of the application's functions.
Some specific info about what I'm doing: (skip down to the last paragraph for the problem)
The left wheel spins a "hundred's" column, and the right wheel spins a "ten's" column, so essentially you're creating one value from two wheels. All I want to do is let the user create a value of 0, 10, 20, 30... 990, 1000 (every ten units up to 1000).The first component is easy to label, but I have two arrays to populate the second component's row's labels. The first array for the second component creates the 00 - 90 label, the second array (for when 1000 is selected) just has a 00 value. So when the user wants to select 1000, the 10 is on the first wheel and 00 on the second. I change the row count for the second wheel component when the first wheel component is at row 10. So now the second component only shows "00". My didSelectRow method uses a matrix for values of 0 - 990 and works great. And I just make a string and convert it to a number for when the user selects 1000 using if statements.
The problem is in the rare circumstance of when the user spins Component 0 to create the value of "1000" (the last row), and if they were start spinning the second component before the first component has a chance to stop spinning (basically spinning in a hurry!), the app crashes. I think it's trying to find a value for a row that doesn't exist. I have other parts of my app that function similarly and they also crash under the same situation. Is there a problem with my approach to changing the number of rows/labels for rows based on the selection of a different component? Or is it something simple in my code?
Thanks for reading and thanks in advance for any help!
Here's the code:
//Baggage Array
baggageHundredsArray = [[NSMutableArray alloc] init];
for (int i = 1; i <= 10; i++) {
NSString *myBagString = [NSString stringWithFormat:#"%d", i];
[baggageHundredsArray addObject:myBagString];
}
[baggageHundredsArray insertObject:#"- " atIndex:0];
baggageTensArray = [[NSMutableArray alloc] init];
for (int i = 10; i <= 90; i = i + 10) {
NSString *myBagString2 = [NSString stringWithFormat:#"%d lbs.", i];
[baggageTensArray addObject:myBagString2];
}
[baggageTensArray insertObject:#"00 lbs." atIndex:0];
baggageTensArray2 = [[NSMutableArray alloc] init];
[baggageTensArray2 insertObject:#"00 lbs." atIndex:0];
- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
if (thePickerView == baggagePicker) {
NSInteger numComps2 = 0;
switch (component)
{
case 0:
numComps2 = [baggageHundredsArray count];
break;
case 1:
if ([baggagePicker selectedRowInComponent:0] <= 9)
{
numComps2 = [baggageTensArray count];
}
else
{
numComps2 = [baggageTensArray2 count];
}
break;
}
return numComps2;
}
}
- (UIView *)pickerView:(UIPickerView *)pickerView
viewForRow:(NSInteger)row
forComponent:(NSInteger)component
reusingView:(UIView *)view {
UILabel *pickerLabel = (UILabel *)view;
if (pickerView == baggagePicker) {
if ((pickerLabel == nil) || ([pickerLabel class] != [UILabel class])) { //newlabel
CGRect frame = CGRectMake(0.0, 0.0, 110, 32.0);
pickerLabel = [[[UILabel alloc] initWithFrame:frame] autorelease];
pickerLabel.textAlignment = UITextAlignmentLeft;
pickerLabel.backgroundColor = [UIColor clearColor];
pickerLabel.font = [UIFont boldSystemFontOfSize:12];
}
pickerLabel.textColor = [UIColor blackColor];
switch (component)
{
case 0:
//CGRect frame = CGRectMake(0.0, 0.0, 80, 32);
//pickerLabel = [[[UILabel alloc] initWithFrame:frame] autorelease];
[pickerLabel setTextAlignment:UITextAlignmentRight];
[pickerLabel setBackgroundColor:[UIColor clearColor]];
[pickerLabel setFont:[UIFont boldSystemFontOfSize:23]];
[pickerLabel setTextColor:[UIColor blackColor]];
[pickerLabel setText:[baggageHundredsArray objectAtIndex:row]];
break;
case 1:
if ([baggagePicker selectedRowInComponent:0] <= 9) {
[pickerLabel setTextAlignment:UITextAlignmentLeft];
[pickerLabel setBackgroundColor:[UIColor clearColor]];
[pickerLabel setFont:[UIFont boldSystemFontOfSize:21]];
[pickerLabel setTextColor:[UIColor blackColor]];
[pickerLabel setText:[baggageTensArray objectAtIndex:row]];
}
else
{
[pickerLabel setTextAlignment:UITextAlignmentLeft];
[pickerLabel setBackgroundColor:[UIColor clearColor]];
[pickerLabel setFont:[UIFont boldSystemFontOfSize:21]];
[pickerLabel setTextColor:[UIColor blackColor]];
[pickerLabel setText:[baggageTensArray2 objectAtIndex:row]];
}
break; }
return pickerLabel;
}
- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if (thePickerView == baggagePicker) {
[baggagePicker reloadAllComponents];
NSInteger hundredsWheel = [thePickerView selectedRowInComponent:0];
NSInteger tensWheel = [thePickerView selectedRowInComponent:1];
//lbs.
int column5 [10][10] = {
{0,10,20,30,40,50,60,70,80,90},
{100,110,120,130,140,150,160,170,180,190},
{200,210,220,230,240,250,260,270,280,290},
{300,310,320,330,340,350,360,370,380,390},
{400,410,420,430,440,450,460,470,480,490},
{500,510,520,530,540,550,560,570,580,590},
{600,610,620,630,640,650,660,670,680,690},
{700,710,720,730,740,750,760,770,780,790},
{800,810,820,830,840,850,860,870,880,890},
{900,910,920,930,940,950,960,970,980,990},
};
// Totals Label
if (hundredsWheel <= 9) {
myBaggageString = [NSString stringWithFormat:#"%i", (column5[hundredsWheel][tensWheel])];
baggageWeightLabel.text = myBaggageString;
baggageWeightInt = [myBaggageString intValue];
baggageWeightFloat = [myBaggageString floatValue];
baggageMomentFloat = baggageWeightFloat * 731.10;
[self calculateWeight];
paxViewBaggageWeightLabel.text = myBaggageString;
NSLog(#"value of myBaggageString is %#", myBaggageString);
[baggagePicker reloadAllComponents];
}
if (hundredsWheel == 10){
myBaggageString = [NSString stringWithFormat:#"1000"];//, [lastFuelValues objectAtIndex: [weightPicker selectedRowInComponent:1]]];
baggageWeightLabel.text = myBaggageString;
baggageWeightInt = [myBaggageString intValue];
baggageWeightFloat = [myBaggageString floatValue];
baggageMomentFloat = baggageWeightFloat * 731.10;
[self calculateWeight];
paxViewBaggageWeightLabel.text = myBaggageString;
[baggagePicker reloadAllComponents];
}

Related

How to get UILabel Tags in iPhone

I am creating labels dynamically from NSMutableArray.While creating labels I have set tags for each label. I have one NSMutableArray named wordArray. Now, I want to check my string is available in wordArray or not,
I can check this using :
[wordArray containsObject:wordStr];
For creating labels dynamically :
UILabel *wordLabl;
int tagValue3 = 1;
for (int iloop = 0; iloop < [wordArray count]; iloop++)
{
wordLabl = [self addwordLabelRect:CGRectMake(80 * iloop + 20, 420 , 100, 20)andTag:tagValue3];//30 + 35 30 * iloop+
[self.view addSubview:wordLabl];
tagValue3 += 1;
}
-(UILabel *)addwordLabelRect:(CGRect)rect andTag:(int)integerValue
{
wordLabel = [[UILabel alloc] init];
wordLabel.frame = rect;
wordLabel.userInteractionEnabled = YES;
wordLabel.tag = integerValue;
wordLabel.backgroundColor = [UIColor clearColor];
wordLabel.font = [UIFont systemFontOfSize:15];
wordLabel.text = [NSString stringWithFormat:#"%#",[wordArray objectAtIndex:integerValue - 1]];
wordLabel.textAlignment = NSTextAlignmentCenter;
wordLabel.textColor = [UIColor whiteColor];
return wordLabel;
}
Using above code I am creating labels and Tags.
But,If wordArray contains the string I want to change the textColor of that label.I think this can be done using Tag , but how can I get the tag value of the label.
Sorry, I overlooked you code... You just need to add following lines where you want to access your appropriate label:
if([wordArray containsObject:wordStr])
{
UILabel *label = (UILabel *) [self.view viewWithTag:([wordArray indexOfObject:wordStr] - 1)];//since u started tag assignment from 1
label.textcolor = [UIColor yellowColor];
}
I guess you're doing something like that to set the tags ?
for (NSUInteger i = 0; i < [wordArray count]; ++i) {
UILabel * label;
// setup your label...
[label setTag:i];
[yourView addSubview:label];
}
If so, just do :
NSUInteger index = [wordArray indexOfObject:wordStr];
if (index != NSNotFound) {
UILabel * label = [yourView viewWithTag:index];
// do whatever you want with your label
}
Good luck.
if you want to get UILabel from its Tag.
you can use following loop
int i=0;
for (NSObject *view in self.View.subviews)
{
if ([view isKindOfClass:[UILabel class]])
{
label = (UILabel *)[[self view] viewWithTag:wordArray[i]];
NSLog(#"%#",label.text);
//here you get your label
}
i++;
}

Zoom a UIScrollview on Objective-C

In one of the projects I'm working on, I have a UIScrollView that has a lot of buttons and labels that resemble movie theater seats that the user can tap to select seats for them to buy. Is it possible to zoom the UIScrollView? I have already declared the UIScrollViewDelegate, set the delegate to self, set the minimum and maximum zoom scale but I'm having issues with the viewForZoomingInScrollView and scrollViewDidEndZooming methods. I tried to return my scrollview on the viewForZoomingInScrollView method but it crashes.
Here's some of the code:
- (void) renderSeatMapOnScreen
{
int x_offset_row = 10;
int y_offset_row = 25;
int x_offset_col = 30;
int y_offset_col = 0;
int scrollview_w = 0;
int scrollview_h = 0;
NSString *row_name = #"";
int tag_index = 0;
NSMutableArray *seat_map_table = [seat_map_xml seats_map];
NSString *seat_available_str = [seat_avail_xml seat_available];
HideNetworkActivityIndicator();
NSLog(#"Seats available = %#", seat_available_str);
NSArray *seats_avail = [seat_available_str componentsSeparatedByString:#";"];
int ROW_COL_OFFSET = 25;
for (int row = 0; row < [seat_map_table count]; row++)
{
UILabel * rowlabel = [[UILabel alloc] init];
rowlabel.frame = CGRectMake(x_offset_row , y_offset_row, 22, 22);
SeatMapDeclaration *rowmap = [seat_map_table objectAtIndex:row];
rowlabel.text = rowmap.rows;
[scrollview addSubview:rowlabel];
row_name = [NSString stringWithFormat:#"%#", rowmap.rows];
NSArray *seat = [rowmap.rowmap componentsSeparatedByString:#";"];
NSLog(#"row[%i] = %#", row, rowmap.rowmap);
if (row == 0)
{
scrollview_w = [seat count] * ROW_COL_OFFSET + y_offset_row;
total_column = [seat count];
total_row = [seat_map_table count];
}
x_offset_col = 30 ;
y_offset_col = y_offset_row ;
for (int column = 0; column < [seat count]; column++)
{
if (([[seat objectAtIndex:column] rangeOfString:#"a("].location != NSNotFound)
|| ([[seat objectAtIndex:column] isEqualToString:#""]))
{
CGRect myImageRect = CGRectMake(x_offset_col, y_offset_col, 22, 22);
UIImageView *imageView = [[UIImageView alloc] initWithFrame:myImageRect];
[imageView setImage:[UIImage imageNamed:#"noseat.png"]];
[scrollview addSubview:imageView];
}
else if ([[seat objectAtIndex:column] rangeOfString:#"b("].location != NSNotFound)
{
CGRect myImageRect = CGRectMake(x_offset_col, y_offset_col, 22, 22);
UIImageView *imageView = [[UIImageView alloc] initWithFrame:myImageRect];
imageView.image = [UIImage imageNamed:#"noseat.png"];
[scrollview addSubview:imageView];
}
else
{
NSString *status = [NSString stringWithFormat:#"%#%#", row_name, [seat objectAtIndex:column]];
BOOL matchedFound = NO;
for (int i = 0; i < [seats_avail count]; i++)
{
if ([[seats_avail objectAtIndex:i] isEqualToString:status])
{
matchedFound = YES ;
break ;
}
}
if (matchedFound == YES)
{
UIButton * seat_btn = [UIButton buttonWithType:UIButtonTypeCustom];
[seat_btn setBackgroundImage:[UIImage imageNamed:#"seatavailable.png"] forState:UIControlStateNormal];
[seat_btn setBackgroundImage:[UIImage imageNamed:#"seatactive.png"] forState:UIControlStateSelected];
seat_btn.frame = CGRectMake(x_offset_col, y_offset_col, 22, 22);
tag_index = [[seat objectAtIndex:column] intValue];
[seat_btn setTitle:[seat objectAtIndex:column] forState:UIControlStateNormal];
seat_btn.titleLabel.font = [UIFont fontWithName:#"Helvetica" size:12.0];
seat_btn.tag = tag_index + row * 100;
[seat_btn addTarget:self
action:#selector(checkboxButton:)
forControlEvents:UIControlEventTouchUpInside];
[scrollview addSubview:seat_btn];
}
else
{
CGRect myImageRect = CGRectMake(x_offset_col, y_offset_col, 22, 22);
UIImageView *imageView = [[UIImageView alloc] initWithFrame:myImageRect];
imageView.image = [UIImage imageNamed:#"seat_not_available.png"];
[scrollview addSubview:imageView];
}
}
x_offset_col += ROW_COL_OFFSET ;
NSString *data = #"";
[seatControl addObject:data];
}
y_offset_row += ROW_COL_OFFSET;
}
UILabel *screenlabel = [[UILabel alloc] init];
screenlabel.frame = CGRectMake((scrollview_w-300)/2, 3, 300, 15);
screenlabel.text = #"Screen";
screenlabel.backgroundColor = [UIColor blackColor];
screenlabel.textColor = [UIColor whiteColor] ;
screenlabel.font = [UIFont fontWithName:#"Helvetica" size:10.0];
screenlabel.textAlignment = UITextAlignmentCenter;
[scrollview addSubview:screenlabel];
scrollview_h = y_offset_row + ROW_COL_OFFSET;
// Adjust scroll view
[scrollview setContentSize:CGSizeMake(scrollview_w, scrollview_h )];
}
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
NSLog(#"1");
return scrollview;
}
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale
{
NSLog(#"2");
}
In:
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
NSLog(#"1");
return scrollview;
}
you are not supposed to return the UIScrollView itself, rather its subview that you would like to scroll/zoom.
If you have many subviews, I would suggest creating a container view for all of them that you return from viewForZoomingInScrollView; instead of adding your seats to the scrollview itself you would then add them to the container view.
If you want to zoom to a certain seat in the UIScrollView, you should use zoomToRect: animated:. You can specify a certain rectangle (i.e. the seat) to which you would like to zoom in on.
Zooming only works when you implement the viewForZoomingInScrollView: delegate callback.
UIImageView *tempImage = [[UIImageView alloc]initWithImage:[UIImage imageWithData:data]];
self.imageView = tempImage;
scrollView.contentSize = CGSizeMake(imageView.frame.size.width , imageView.frame.size.height);
scrollView.maximumZoomScale = 1;
scrollView.minimumZoomScale = .37;
scrollView.clipsToBounds = YES;
scrollView.delegate = self;
[scrollView addSubview:imageView];
scrollView.zoomScale = .37;
-(UIView *) viewForZoomingInScrollView:(UIScrollView *)inScroll {
return imageView;
}

uislider adding uitextfield but not updating

So, I have the slider adding UITextFields but it's not updating/subtracting UITextField's when selecting less than the previous Slider Value. Does [self.view addSubview:textField]; need to be outside of the for loop? Thanks in advance.
- (IBAction) sliderValueChanged:(UISlider *)sender {
float senderValue = [sender value];
int roundedValue = senderValue * 1;
ingredientLabel.text = [NSString stringWithFormat:#"%d", roundedValue];
int moveYBy = 35;
int baseY = 140;
for(int y = 0; y < roundedValue; y++){
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(20, baseY, 227, 31)];
textField.text = [NSString stringWithFormat:#"%d", roundedValue];
textField.borderStyle = UITextBorderStyleRoundedRect;
baseY = baseY + moveYBy;
[self.view addSubview:textField];
[textField release];
NSLog(#"Adding %d fields!", roundedValue);
}
NSLog(#"%d", roundedValue);
}
You are creating N text fields everytime the slider value changes (where n is the rounded value).
Instead, you should make an NSMutableArray an iVar and store all the text fields there, when roundedValue is bigger than the number of text fields in that array, we add more. When it's smaller, we remove some.
(I'm using an iVar called textFieldsArray, and I also changed a little the way the y is calculated for the arrays)
- (IBAction) sliderValueChanged:(UISlider *)sender {
float senderValue = [sender value];
int roundedValue = senderValue * 1;
ingredientLabel.text = [NSString stringWithFormat:#"%d", roundedValue];
for(int y = 0; y < roundedValue; y++){
if(y > [textFieldsArray count]){
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 140 + 35 * y, 227, 31)];
textField.text = [NSString stringWithFormat:#"%d", roundedValue];
textField.borderStyle = UITextBorderStyleRoundedRect;
[self.view addSubview:textField];
[textFieldsArray addObject:textField];
[textField release];
NSLog(#"Adding %d fields!", roundedValue);
}
}
while([textFieldsArray count] > roundedValue){
UITextField *textField = [textFieldsArray lastObject];
[textField removeFromSuperview];
[textFieldsArray removeLastObject];
}
NSLog(#"%d", roundedValue);
}

One UIPickerView Two Data Sources/Views works once then crashes

I am trying to display a single UIPickerView in my app and depending on what button is selected a UIPickView will popup and populate with the relevant data for the button selected. No sure if it matters but one UIPickerView has three columns and one has two. I can get both of them to work perfectly when the are separate but the minute that I nest them into if statements it breaks.
On the third time when I select the button that fires the opposite UIPickerView it crashes and give me the error of NSRangeException and that it is trying to find the object at index 2 in an array [0...1]. My understanding is that the program thinks that there is an object in a spot in the array that doesn't exist.
I have tried the [picker reloadAllComponents] method and have it called each time the button is selected but as stated above that only works once and then it quits. The strange thing is that if I select the button that I pressed for the second set of code it works perfectly. It is when I select a button that would make the UIPickerView have to change its view that it crashes.
I am really new to iOS development and Objective C and hope that someone out there knows what I am doing wrong. I will post any code that you guys need and will post a couple samples just to understand what is going on.
Here is one of the buttons methods that sets an int to 2 and also calls the method to show the picker.
-(IBAction)linePopupPicker{
picker = 2;
[self pickerShow];
}
This code is the other method which is pretty much the same as the other (I am aware that I haven't implemented the UserDefaults into the second button yet)
-(IBAction)namePicker{
field = 1;
picker = 1;
NSLog(#"The value of field is:%i", field);
NSUserDefaults *pickerViewSelectionDefaults = [NSUserDefaults standardUserDefaults];
[tipPicker selectRow:[pickerViewSelectionDefaults integerForKey:#"pickerViewSelectionKey"] inComponent:0 animated:NO];
[tipPicker selectRow:[pickerViewSelectionDefaults integerForKey:#"pickerViewNameColor"] inComponent:1 animated:NO];
[tipPicker selectRow:[pickerViewSelectionDefaults integerForKey:#"pickerViewNameFontSize"] inComponent:2 animated:NO];
[self pickerShow];
}
This is the method that calls the UIPickerView. I have it so that it emerges onto the view rather than being static. I thought that this would be the best place to reload the components.
-(IBAction)pickerShow{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
CGAffineTransform transform = CGAffineTransformMakeTranslation(0, 240);
pickerView.transform = transform;
[self.view addSubview:pickerView];
[tipPicker reloadAllComponents];
[UIView commitAnimations];
}
Finally here is just a sample of the code that is used throughout the various methods that need to be called for the UIPickerView.
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {
if (picker ==2) {
switch (component)
{
case 0:
{
UILabel *lineColorLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 130, 44)] autorelease];
lineColorLabel.backgroundColor = [UIColor clearColor];
NSString *lineTempColor = [colorArray1 objectAtIndex:row];
//NSLog(#"The String Color Name:%#", tempColor);
UIColor *myColor1 = [UIColor performSelector:NSSelectorFromString(lineTempColor)];
lineColorLabel.backgroundColor = myColor1;
return lineColorLabel;
}
case 1:
{
UILabel *alphaLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0,40, 44)] autorelease];
alphaLabel.text = [alphaArray objectAtIndex:row];
alphaLabel.font = [UIFont systemFontOfSize:18];
alphaLabel.textAlignment = UITextAlignmentCenter;
alphaLabel.backgroundColor = [UIColor clearColor];
alphaLabel.shadowColor = [UIColor whiteColor];
return alphaLabel;
}
default:
break;
}
}
else if (picker == 1)
{
switch (component)
{
case 0:
{
UILabel *fontLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 130, 44)] autorelease];
fontLabel.backgroundColor = [UIColor clearColor];
fontLabel.shadowColor = [UIColor whiteColor];
fontLabel.text = [fontNames objectAtIndex:row];
NSString *font = [fontNames objectAtIndex:row];
fontLabel.font = [UIFont fontWithName:font size:18.0];
fontLabel.textAlignment = UITextAlignmentLeft;
return fontLabel;
}
case 1:
{
UILabel *colorLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 35, 44)] autorelease];
NSString *tempColor = [colorArray objectAtIndex:row];
//NSLog(#"The String Color Name:%#", tempColor);
UIColor *myColor = [UIColor performSelector:NSSelectorFromString(tempColor)];
colorLabel.backgroundColor = myColor;
return colorLabel;
}
case 2:
{
UILabel *sizeLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0,40, 44)] autorelease];
sizeLabel.text = [fontSizeArray objectAtIndex:row];
sizeLabel.font = [UIFont systemFontOfSize:18];
sizeLabel.textAlignment = UITextAlignmentCenter;
sizeLabel.backgroundColor = [UIColor clearColor];
sizeLabel.shadowColor = [UIColor whiteColor];
return sizeLabel;
}
default:
break;
}
}
return 0;
}
Here are the data methods:
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {
if (picker == 2) {
return 2;
}else if (picker == 1) {
return 3;
}
//return 3;
}
- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component { // This method also needs to be used. This asks how many rows the UIPickerView will have.
if (picker == 2) {
if (component == 0) {
return [colorArray1 count];
}
return [alphaArray count];
}else if (picker == 1) {
if (component == 0) {
return [fontNames count];
}else if (component == 1) {
return [colorArray count];
}
return [fontSizeArray count];
}
}
I hope this post provides all of the information that is need to help me get this fixed. I really appreciate it and hope that I am just missing something really simple. Thank you in advanced.
I am really new to iOS development and Objective C so this problem is really stumping me.
case 1 in the if ( picker == 2) switch statement has an opening brace but no closing one.
EDIT
- (void) savePickerOne {
[pickerViewSelectionDefaults setInteger:[tipPicker selectedRowInComponent:0] ForKey:#"pickerViewSelectionKey"];
[pickerViewSelectionDefaults setInteger:[tipPicker selectedRowInComponent:1] ForKey:#"pickerViewNameColor"];
[pickerViewSelectionDefaults setInteger:[tipPicker selectedRowInComponent:2] ForKey:#"pickerViewNameFontSize"];
}

Lable not appearing in UITable Cell

Have a problem where my Label is not appearing. But the slider does. Its one of these bizarre cases that seems there is no logical reason. Anybody able to make sense of this?
else if (indexPath.row == 4)
{
Filters *filters = [Filters sharedInstance];
CGRect frame = CGRectMake(100, 10, 80, 23);
costSlider = [[[UISlider alloc] initWithFrame:frame] autorelease];
costSlider.maximumValue = [[NSNumber numberWithDouble:
filters.maxCarRentalCost] floatValue];
costSlider.minimumValue = [[NSNumber numberWithDouble:
filters.minCarRentalCost] floatValue];
[costSlider addTarget:self action:#selector(costSliderChanged:)
forControlEvents:UIControlEventValueChanged];
[costSlider setValue:[filters.maxCarCostPerDay floatValue] animated:YES ];
costSlider.continuous = NO;
costSlider.enabled = YES;
costSlider.value = [filters.maxCarCostPerDay floatValue];
costSlider.tag = 5;
[cell addSubview:costSlider];
self.costLabel.textColor = [UIColor greenColor];
self.costLabel.text = #"what"; //[NSString stringWithFormat:#"Cost per day:
%d", filters.maxCarCostPerDay ];
[self.costLabel setBackgroundColor:[UIColor blueColor]];
self.costLabel.frame = CGRectMake(10, 10, 75, 20);
[self.costLabel setFont:[UIFont boldSystemFontOfSize:10.0]];
[cell addSubview:self.costLabel];
}
Thanks
-Code
From the code you posted it does not look like you have alloc'd the label. Unless you are doing that elsewhere in the code, that is probably your issue