iOS SDK - issue changing UIPicker font size. strange behavior
I can not understand why this code does not work
I am using this delegate method to resize the font (i dont bother showing
that because its not relevant)
- (UIView *)pickerView:(UIPickerView *)pickerView
viewForRow:(NSInteger)row forComponent:(NSInteger)component
reusingView:(UIView *)view;
this is a multi picker. i have three components. When I run the code with
a conditional statement using else, it makes section 0 match section 2. I
can't explain this
NSLog(@"%i", component); // only prints, 0, 1, 2
NSString *theString = @"";
if(component == 0){
theString = [_phosType objectAtIndex:row];
}
if(component == 1){
theString = [_quantity objectAtIndex:row];
} else { // THIS CAUSES PROBLEMS.
theString = [_units objectAtIndex:row];
}
pickerViewLabel.text = theString;
this one works.. what gives!
NSLog(@"%i", component); // only prints, 0, 1, 2
NSString *theString = @"";
if(component == 0){
theString = [_phosType objectAtIndex:row];
}
if(component == 1){
theString = [_quantity objectAtIndex:row];
}
if(component == 2){ // THIS WORKS! BUT WHY?!
theString = [_units objectAtIndex:row];
}
pickerViewLabel.text = theString;
why do i need to explicitly ask if component is 2? i can see when I NSLog
component that it never equals anything other than 0 1 or 2. I'm using
'else' everywhere else in the code and having the problem. Can anyone
explain this?
No comments:
Post a Comment