1) Inside viewDidAppear
, you'll want to set the text of the UITextField
s --
[self textFieldName] setText:@"0.00"];
2) Your controller should adhere to UITextFieldDelegate
and it should I would implement it something like the following --
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSCharacterSet *characterSet = [[NSCharacterSet characterSetWithCharactersInString:@"0123456789."] invertedSet];
NSString *filtered = [[string componentsSeparatedByCharactersInSet:characterSet] componentsJoinedByString:@""];
return [string isEqualToString:filtered];
}
3) To reset the text field, I would implement the UITextFieldDelegate
method as follows --
- (void)textFieldDidEndEditing:(UITextField *)textField
{
if ([[textField text] isEqualToString:@""]) {
[textField setText:@"0.00"];
}
}
Post a comment if you have a further questions. Good luck.