There are two ways, second is the easy way.
1) define delegate and
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
2)
-(void)touchesBegan: (NSSet *)touches withEvent:(UIEvent *)event
{
// do the following for all textfields in your current view
[self.txtfieldname resignFirstResponder];
// save the value of the textfield, ...
}
3) Dismiss textview
Define Delegate
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
if([text isEqualToString:@"\n"]) {
[textView resignFirstResponder];
return NO;
}
return YES;
}
1) define delegate and
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
2)
-(void)touchesBegan: (NSSet *)touches withEvent:(UIEvent *)event
{
// do the following for all textfields in your current view
[self.txtfieldname resignFirstResponder];
// save the value of the textfield, ...
}
3) Dismiss textview
Define Delegate
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
if([text isEqualToString:@"\n"]) {
[textView resignFirstResponder];
return NO;
}
return YES;
}
No comments:
Post a Comment