本文介绍了使用多个文本字段解除第一响应者/键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过这样认真的认真...

Like seriously after going through this...

...我有多个 TextFields 和一些 TextViews 。是否有办法让所有文本字段都有批处理或组Dismiss First Responder?我需要为每个领域制作方法吗?也许我忽略了该链接中的某些内容?

... I have multiple TextFields and a few TextViews. Is there not a way to a have a batch or group Dismiss First Responder for all text fields? Will I need to make method for each field? Maybe I overlooked something in that link?

也许我可以遵循以下内容:

Maybe I can follow something like this:

后者有意义吗?在此先感谢。

Would the latter make sense? Thanks in advance.

= - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

我想出来......

I figured it out....

Controller.h

@interface Controller : UIViewController <UITextFieldDelegate> {
    IBOutlet UITextField *clickedDone;
}
@property (nonatomic, retain) IBOutlet UITextField *clickedDone;

Controller.m

#import "Controller.h"
@implementation Controller
@synthesize clickedDone;

- (void)viewDidLoad
{
    [super viewDidLoad];
    [clickedDone setDelegate:self];
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField resignFirstResponder];
    return YES;    
}


推荐答案

clickedDone.returnKeyType = UIReturnKeyDone;  // in viewDidLoad

- (BOOL)textFieldShouldReturn:(UITextField *)textField 
{
   [textField resignFirstResponder];
   return YES;    
}

这篇关于使用多个文本字段解除第一响应者/键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 01:11