ios – 使用多个文本字段解除第一响应者/键盘

前端之家收集整理的这篇文章主要介绍了ios – 使用多个文本字段解除第一响应者/键盘前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
经过这个……

Easy way to dismiss keyboard?

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

也许我可以遵循这样的事情:

https://stackoverflow.com/questions/3282837/problem-with-multiple-textfields-to-make-the-keyboard-dissapear

后者会有意义吗?提前致谢.

= – = – = – = – = – = – = – = – = – = – = – = – = – = – = – = – = – = – = – = – = – = – = – = – = – = –

我想到了….

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;    
}@H_301_17@

解决方法

clickedDone.returnKeyType = UIReturnKeyDone;  // in viewDidLoad

- (BOOL)textFieldShouldReturn:(UITextField *)textField 
{
   [textField resignFirstResponder];
   return YES;    
}@H_301_17@
原文链接:https://www.f2er.com/iOS/333992.html

猜你在找的iOS相关文章