[英]Need help with unit converter app getting uipicker to call a function
少量代码使事情有些生气
- (void)pickerView:(UIPickerView *)
thePickerView didSelectRow:
(NSInteger)rowinComponent:(NSInteger)component {
if ( row ==1) {
-(IBAction)presstoconvert{
float number1 = ([initamount.text floatValue ]);
float answer = number1 *12;
result.text = [[NSString alloc]initWithFormat:@"%2.f", answer];
}
}
else ( row == 2);{
float number1 = ([initamount.text floatValue ]);
float answer = number1 /12;
result.text = [[NSString alloc]initWithFormat:@"%2.f", answer];
}
}
为什么要在didSelectRow:
定义一个pressToConvert
? 只需删除- (IBAction)presstoconvert{
和相应的}
,就可以了。
否则,您可以将pressToConvert
此方法主体之外,然后从此处调用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.