gpt4 book ai didi

iOS 7 如何获取当前选定的 UITextField id

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:02:40 26 4
gpt4 key购买 nike

调用 dismissKeyboard 时,我将每个 UITextField 添加到 resignFirstResponder。

有没有办法获取当前选定的 UITextField 的 ID 并使其成为 resignFirstResponder?

#import "NewBabyViewController.h"

@interface NewBabyViewController ()
@property (weak, nonatomic) IBOutlet UITextField *BabyName;
@property (weak, nonatomic) IBOutlet UITextField *BabyNickname;
@end

@implementation NewBabyViewController

- (void)viewDidLoad
{
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(dismissKeyboard)
];
[self.view addGestureRecognizer:tap];
}

-(void)dismissKeyboard{

[self.view endEditing:YES];
//[self.BabyName resignFirstResponder];
//[self.BabyNickname resignFirstResponder];
}

-(IBAction)textFieldDone:(id)sender
{
[sender resignFirstResponder];
}

@end

最佳答案

这个问题的解决方案并不十分明显,但实际上非常容易解决。只需使用以下内容:

-(void)dismissKeyboard {
[self.view endEditing:YES];
}

关于iOS 7 如何获取当前选定的 UITextField id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19992259/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com