Textfield中整数的乘法 - Xcode 4.4

时间:2012-08-14 00:09:02

标签: objective-c ios xcode4 xcode4.2 xcode4.3

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

@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中显示产品。有人可以帮忙实施吗?非常感谢!

1 个答案:

答案 0 :(得分:0)

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

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

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