gpt4 book ai didi

ios - 在移动到下一个 Controller Swift iOS 之前错误隐藏键盘

转载 作者:行者123 更新时间:2023-11-28 12:28:11 27 4
gpt4 key购买 nike

我想在移动到下一个 Controller 之前隐藏键盘。同时在 viewWillDisapear 中实现 self.view.enditing(true) 。但是keybard不隐藏怎么隐藏呢?

func textFieldDidBeginEditing(_ textField: UITextField) {

if textField == tagTxt{
self.view.endEditing(true)
textField.resignFirstResponder()
let interstControlle = self.storyboard?.instantiateViewController(withIdentifier: "InterestViewController") as! InterestViewController
interstControlle.PContId = "InterestViewController"
interstControlle.delegate = self
if tagsID.count > 0{
interstControlle.PTagsID = tagsID
}
self.navigationController?.pushViewController(interstControlle, animated: true)
}
}

最佳答案

使用这个:

-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
if textField == tagTxt{
return NO;
}
return YES;
}

swift 3:

func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
if textField == tagTxt{
return false
}
return true
}

关于ios - 在移动到下一个 Controller Swift iOS 之前错误隐藏键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42856533/

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