Need help with unit converter app getting uipicker to call a function
something is going haw ire in tis bit of code
- (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 answe开发者_Python百科r = number1 /12;
result.text = [[NSString alloc]initWithFormat:@"%2.f", answer];
}
}
Why have you defined an pressToConvert
inside didSelectRow:
? Just remove -(IBAction)presstoconvert{
& the corresponding }
& you should be good.
Otherwise, you could move pressToConvert
outside this method body and call it from here.
精彩评论