[NSString stringWithFormat:@"%f",monthButtonTitle];
实现UITextFieldDelegate
yourTextField.delegate = self // self maybe the controller;
然后在方法中
- (void)textFieldDidEndEditing:(UITextField *)textField
获取您输入的新值
float v = [textField.text floatValue];
计算它,更新标签
如果你只允许输入数字,你可以这样做
textField.keyboardType = UIKeyboardTypeNumberPad;
#define NUMBERSPERIOD @"0123456789."
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSCharacterSet *cs = [[NSCharacterSet characterSetWithCharactersInString:NUMBERSPERIOD] invertedSet];
NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
BOOL basicTest = [string isEqualToString:filtered];
// Add any predicate testing here
return basicTest;
}