【问题标题】:Need help with unit converter app getting uipicker to call a function需要帮助单位转换器应用程序让 uipicker 调用函数
【发布时间】:2011-08-30 06:28:13
【问题描述】:

这一段代码有点不对劲

      - (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];
}

}

【问题讨论】:

    标签: iphone ios xcode4


    【解决方案1】:

    为什么在didSelectRow: 中定义pressToConvert?只需删除 -(IBAction)presstoconvert{ 和相应的 } 就可以了。

    否则,您可以将pressToConvert 移出此方法体并从此处调用它。

    【讨论】:

    • 谢谢你顺便说一句,我认为我正在展示的唯一原因是因为我有一个按钮,当你按下它时它就会转换。我希望 ui 选择器选择转换,然后当用户输入他们想要转换的金额时,他们会点击按钮。身份证
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-13
    • 2020-01-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多