0

我正在尝试将三个不同文本字段中的整数值相乘。

@property (nonatomic,strong) IBOutlet UITextField *textField;
@property (nonatomic,strong) IBOutlet UITextField *textField2;
@property (nonatomic,strong) IBOutlet UITextField *textField3;
@property (nonatomic,strong) IBOutlet UILabel *total;

我正在尝试在 UILabel 中显示产品。有人可以帮助实施吗?非常感谢!

4

1 回答 1

0

要在 UILabel 中显示产品,请以这种方式设置标签文本(假设 textFields 都包含整数):

total.text = [NSString stringWithFormat: @"%i", (textField.text.intValue * textField2.text.intValue * textField3.text.intValue)];

你可能想把它放在一个单独的方法中,这样你就可以从任何地方调用它,比如每当用户用新数字更新 textFields 时

于 2012-08-14T00:15:40.997 回答