KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Ok, maybe I'm missing something really simple and I apologize if that's the case, however, I've googled every permutation of the title and have not found! So this is simply what I want to do: change the background color of the label I'm using as the row view in a 2 component pickerview when that row has been selected. So I thought this would work: if (row == [pickerview selectedRowForComponent]) viewlabel.backgroundColor = redcolor; but this doesn't work. It seems to arbitrarily choose which row to color and sometimes even give a bad access error. I've tried all different clauses to no effect! ANy suggestions would be greatly appreciated!! Here's the full method: - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { if (component == kNumberComponent) { #define PICKER_LABEL_FONT_SIZE 24 #define PICKER_LABEL_ALPHA 1.0 // UIFont *font = [UIFont boldSystemFontOfSize:PICKER_LABEL_FONT_SIZE]; UIFont *font = [ UIFont fontWithName:@"AppleGothic" size:24]; UILabel *carsLabel =[ [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 75, 50) ]autorelease]; //[picker selectRow:row inComponent:component animated:YES]; NSString *pickerText = [self.numbers objectAtIndex:(int)row]; carsLabel.text = pickerText; carsLabel.textAlignment = UITextAlignmentCenter; NSLog(@"carsLabel = %@",carsLabel.text); //carsLabel.text = @"maybe because the string isn't long enough"; carsLabel.textColor = [UIColor blackColor]; carsLabel.font = font; carsLabel.opaque = YES; [view addSubview:carsLabel]; return carsLabel; } else { UIFont *font = [ UIFont fontWithName:@"AppleGothic" size:18]; UILabel *carsLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 225, 50)] autorelease]; id fact
Tags (comma-separated)
Save Edits
Cancel