我对 xcode 很陌生,我对我的第一个应用程序有疑问。我的应用程序中有一个 UIPickerView,其中包含 2 个组件,其中填充了 NSMutableArray。如果第一个组件发生更改,则第二个组件数组将被清除并填充新值。现在我必须检测第一个组件中的选定行和第二个组件中的选定行,以在 UIWebView 中加载本地 HTML 页面。我会用 if 循环尝试它,但我不明白如何检测 2 个组件上的所有选定行。这是我的源代码的一小段:
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
NSLog(@"the %d row was selected in the %d component", row, component);
if ((component == 0) && (row ==0)){
[rightPickerArray removeAllObjects];
[rightPickerArray addObject:@"5.0"];
[rightPickerArray addObject:@"5.1"];
[pickerView reloadAllComponents];
}
if ((component == 0) && (row ==1)){
[rightPickerArray removeAllObjects];
[rightPickerArray addObject:@"1"];
[rightPickerArray addObject:@"2"];
[pickerView reloadAllComponents];
}
if ((component ==1) && (row ==0)){
NSString *fileString = [[NSBundle mainBundle] pathForResource:@"index" ofType: @"html"];
NSString *newHTMLString = [[NSString alloc] initWithContentsOfFile: fileString encoding: NSASCIIStringEncoding error: NULL];
NSURL *newURL = [[NSURL alloc] initFileURLWithPath: fileString];
[myWebView loadHTMLString: newHTMLString baseURL: newURL];
}