0

I created the textfield programmatically for getting the value in it. Once i got the value in the textfield i wanted to dismiss the keyboard.

Could anyone help me in this with sample code?

Thanks in advance.

0

4 Answers 4

3

If you are asking about iOS' keyboard, then you can do this:

[textField resignFirstResponder]; 

When a UITextField gains focus, it is said to have "gained first responder status", meaning that it is the first UIResponder in the responder chain. What this means to you is that when you send the resignFirstResponder message to a UIResponder, the receiver will be popped off the responder chain and the next responder in the chain will gain first responder status.

Sign up to request clarification or add additional context in comments.

Comments

2
[inputView resignFirstResponder]; 

Comments

1

Create a text field delegate method that would send resignFirstResponder message to text field in question when "return" button is pressed:

// in some method [myTextField setDelegate:self]; - (BOOL)textFieldShouldReturn:(UITextField *)textField { [myTextField resignFirstResponder]; return YES; } 

This code is off top of my head so doublecheck the delegate method title.

Comments

0

have one button Action

 UIButton *keyboard=[UIButton buttonWithType:UIButtonTypeCustom]; keyboard.frame = CGRectMake(0,100,320,460); [keyboard addTarget:self action:@selector(keyDown) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:keyboard]; 

in button action write this code

 -(void)keyDown{ [textfield resignFirstResponder]; 

}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.