私が最初にUIPickerView使用2 UIPickerView
- (void)viewDidLoad
NSURL *url = [NSURL URLWithString:
@"http://localhost:8080/Data/resources/converter.country/"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request startAsynchronous];
// countrys = [[UIPickerView alloc] init];
countrys.delegate = self;
countrys.dataSource = self;
countrys.showsSelectionIndicator = YES;
countryField.inputView=countrys;
- (NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
NSString *codeCity;
codeCity=[countriesArray objectAtIndex:row];
return codeCity;
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
return [countriesCodeArray count];
}
ため、このコードを書いたし、私は都市で別のUIPickerViewを作りたかったです。私はこれを書いた
citys.delegate = self;
citys.dataSource = self;
citys.showsSelectionIndicator = YES;
cityField.inputView=citys;
しかし、私がそれをクリックすると私は国のリストを持っています。データソースをどのように変更する必要がありますか?また、numberOfComponentsInPickerView、numberOfRowsInComponent:...のようなUIPickerViewのデフォルト関数を使用する方法は、2番目のUIPickerView?
また、 "if(pickerView == cityPickerView)..."を使用することもできます。 – giuseppe