[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;
}