【发布时间】:2011-10-17 01:54:28
【问题描述】:
我正在尝试使用具有三个组件的 UIPickerView 创建一个应用程序。第一个组件有 3 行。第二个组件有 6 行,第三个组件有 12 行。每次我滚动超出组件 2 或 3 中的第 3 行时,应用程序都会崩溃并指向第一个组件数组。我确信这很容易解决,但我迷路了。提前致谢。
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row
inComponent:(NSInteger)component
{
{
NSString *resultString0 = [[NSString alloc] initWithFormat:
@"Sensor: %@",
[modelArray objectAtIndex:row]];
modelLabel.text = resultString0;
[resultString0 release];
}
{
NSString *resultString1 = [[NSString alloc] initWithFormat:
@"Pixels: %@",
[memoryArray objectAtIndex:row]];
memoryLabel.text = resultString1;
[resultString1 release];
NSString *firstString = horizFaceRecLabel.text;
float horizontalFace = [[horizontalArray objectAtIndex:row] floatValue];
float requiredFace = 100;
output1 = [firstString floatValue];
output1 = horizontalFace / requiredFace;
horizFaceRecLabel.text = [NSString stringWithFormat:(@"%.1f ft"), output1];
NSString *secondString = horizLicensePlateLabel.text;
float horizontalLicense = [[horizontalArray objectAtIndex:row] floatValue];
float requiredLicense = 45;
output2 = [secondString floatValue];
output2 = horizontalLicense / requiredLicense;
horizLicensePlateLabel.text = [NSString stringWithFormat:(@"%.1f ft"), output2];
NSString *thirdString = horizVisualIdLabel.text;
float horizontalVisual = [[horizontalArray objectAtIndex:row] floatValue];
float requiredVisual = 30;
output3 = [thirdString floatValue];
output3 = horizontalVisual / requiredVisual;
horizVisualIdLabel.text = [NSString stringWithFormat:(@"%.1f ft"), output3];
}
{
NSString *resultString2 = [[NSString alloc] initWithFormat:
@"Lens: %@",
[lensArray objectAtIndex:row]];
lensLabel.text = resultString2;
[resultString2 release];
{
NSString *firstDistString = faceRecLabel.text;
float angle = [[anglesArrayA objectAtIndex:row] floatValue];
float densityOne;
float densityTwo;
densityOne = [firstDistString floatValue];
densityTwo = (output1/2)/(sin(angle/2));
faceRecLabel.text = [NSString stringWithFormat:(@"%.1f ft"), densityTwo];
}
}
}
【问题讨论】:
标签: objective-c xcode xcode4 ios4 uipickerview