Semplice, con questi due metodi è possibile ripristinarla al punto iniziale cliccando su di un qualsiasi punto dello schermo.
Con Xcode collegare il metodo a "Editing Did End" del campo testo.
- (void)textViewDidEndEditing:(UITextView *)textView
{
CGAffineTransform translateUp = CGAffineTransformMakeTranslation(0.0, 0.0);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.2];
self.view.transform = translateUp;
[UIView commitAnimations];
}
//fieldName: UITextField defined in File.h
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
if ([fieldName isFirstResponder] && [touch view] != fieldName) {
[fieldName resignFirstResponder];
}
else if ([fieldCountry isFirstResponder] && [touch view] != fieldCountry) {
[fieldCountry resignFirstResponder];
}
[super touchesBegan:touches withEvent:event];
}