正如标题所说,有没有办法在pickerview中调用didSelectrow?我正在研究我的第一个“大”项目(货币转换器),这是一个我似乎无法弄清楚的问题。这是从.m文件中获取的一些代码:
//Toggle reverse on/off
- (IBAction)Reverse:(id)sender {
reverse = (reverse+1)%2;
NSString *tmpstring = string1;
string1 = string2;
string2 = tmpstring;
if (!reverse) {
[Picker1 selectRow:row2 inComponent:0 animated:YES];
[Picker1 selectRow:row1 inComponent:1 animated:YES];
Text1.text = [Datarray objectAtIndex:row2];
} else {
[Picker1 selectRow:row1 inComponent:0 animated:YES];
[Picker1 selectRow:row2 inComponent:1 animated:YES];
Text1.text = [Datarray objectAtIndex:row1];
}
tmpstring = nil;
[self Editingdidend:self];
NSLog(@"%d",reverse);
//[call didSelectRow here]
}
-(void) pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
XMLparse *parse = [[XMLparse alloc]init];
if (component == 0) {
Text1.text = [Datarray objectAtIndex:row];
string1 = [Datarray objectAtIndex:row];
row1 = row;
[parse setHowmuchmoney:[Inputter.text floatValue]];
[parse setValutanamn1:string1];
[parse setValutanamn2:string2];
[parse loadDataFromXML];
Output.text = [NSString stringWithFormat:@"%.2f", [parse convertionrate]];
} else {
string2 = [Datarray objectAtIndex:row];
row2 = row;
[parse setHowmuchmoney:[Inputter.text floatValue]];
[parse setValutanamn1:string1];
[parse setValutanamn2:string2];
[parse loadDataFromXML];
Output.text = [NSString stringWithFormat:@"%.2f", [parse convertionrate]];
}
}