我是iPhone开发的新手。
我有一个UITextField,当我按下输入时我需要隐藏键盘......
任何方式来实现这一目标..
感谢您的帮助和感谢您的时间
答案 0 :(得分:2)
实施UITextFieldDelegate
协议的textFieldShouldReturn:
方法,并根据传入的对象返回YES
。
- (BOOL) textFieldShouldReturn:(UITextField *) textField {
[textField resignFirstResponder];
return (textField == someTextField);
}
答案 1 :(得分:2)
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
答案 2 :(得分:0)
答案 3 :(得分:0)
First if the textfield global object is myTextField then <br>
In .h file <br>
@interface MyScreen : UIViewController <**UITextFieldDelegate**>
{
UITextField *myTextField;
}
@property (nonatomic,retain) IBOutlet UITextField ***myTextField**;<br>
In .xib <br>
Attach myTextField to the control.<br>
In .m File <br>
- (void) viewDidLoad<br>
{
[super viewDidLoad];
myTextField.delegate = self;
}
If you want to return the keyboard on particular return button of keyboard press: <br>
#pragma mark UITextFieldDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
If you want to return on your particular button <br>
- (IBAction) myButtonPressed:(id)sender
{
[self.myTextField resignFirstResponder];
}
Apologise for my bad english.
Thanks & Regards,
Gautam Tiwari
Ios Application Developer