Silver Challenge Solution


#1

One method within BNRDetailViewController. I extended mine to dismiss more than just the number pad as I think the same should be true of the other fields.

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self.nameField resignFirstResponder];
    [self.serialNumberField resignFirstResponder];
    [self.valueField resignFirstResponder];
}

#2

[quote=“C6silver”]One method within BNRDetailViewController. I extended mine to dismiss more than just the number pad as I think the same should be true of the other fields.

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self.nameField resignFirstResponder]; [self.serialNumberField resignFirstResponder]; [self.valueField resignFirstResponder]; } [/quote]
This is the same solution I came up with, too. I didn’t extend it to the other text fields, though, but that’s a really good idea.


#3

In my case, I introduced ‘Done’ button next to the value field appearing with keyboard to dismiss it, but utilizing touch seems a better idea.

-(void)textFieldDidBeginEditing:(UITextField *)textField
{
    if (textField == self.valueField) {
        self.valueDoneButton.hidden = NO;
    }
}

-(void)textFieldDidEndEditing:(UITextField *)textField
{
    if (textField == self.valueField) {
        [self endEditingValue:textField];
    }
}

-(IBAction)endEditingValue:(id)sender
{
    self.valueDoneButton.hidden = YES;
    [self.valueField resignFirstResponder];
}