我正在使用小数键盘进行一些用户输入。使用这个键盘,我无法使用“完成”键来取消键盘,所以我已经制作了一个按钮来隐藏它,它工作正常。
我的第一个问题是,如何在键盘出现“
时才显示此按钮我的第二个问题(对不起,我对Xcode很新!) 一旦用户输入了6个textFields中的正确值,我就必须添加一些计算并在单独的textField中显示结果,例如: textField1 * textField2 / textField3 + textField4 * 150 = ......
非常感谢任何帮助,谢谢。
伊恩。
这是我的.m文件(完成(IBAction))是我的按钮:
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)done:(id)sender {
[textField1 resignFirstResponder];
[textField2 resignFirstResponder];
[textField3 resignFirstResponder];
[textField4 resignFirstResponder];
[textField5 resignFirstResponder];
[textField6 resignFirstResponder];
}
- (IBAction)textFieldNumber1:(id)sender {
}
- (IBAction)textFieldNumber2:(id)sender {
}
- (IBAction)textFieldNumber3:(id)sender {
}
- (IBAction)textFieldNumber4:(id)sender {
}
- (IBAction)textFieldNumber5:(id)sender {
}
- (IBAction)textFieldNumber6:(id)sender {
}
这是我的.h文件:
#import <UIKit/UIKit.h>
@interface benoViewController : UIViewController
{
IBOutlet UITextField *textField1;
IBOutlet UITextField *textField2;
IBOutlet UITextField *textField3;
IBOutlet UITextField *textField4;
IBOutlet UITextField *textField5;
IBOutlet UITextField *textField6;
}
- (IBAction)done:(id)sender;
- (IBAction)textFieldNumber1:(id)sender;
- (IBAction)textFieldNumber2:(id)sender;
- (IBAction)textFieldNumber3:(id)sender;
- (IBAction)textFieldNumber4:(id)sender;
- (IBAction)textFieldNumber5:(id)sender;
- (IBAction)textFieldNumber6:(id)sender;
@end
答案 0 :(得分:0)
尝试
[self.textFielX endEditing:YES];