uiview – swift中的resignFirstResponder

前端之家收集整理的这篇文章主要介绍了uiview – swift中的resignFirstResponder前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何用Apple的新语言实现它?

Objective-C代码

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
        for (UIView *view in self.view.subviews)
        [view resignFirstResponder];
}

我试图这样做.但是键盘并没有消失:

SWIFT代码

override func touchesBegan(touches: NSSet,withEvent event: UIEvent) {
    super.touchesBegan(touches,withEvent: event)
    self.view.resignFirstResponder()
}
你可能会去:
self.view.endEditing(true)
原文链接:https://www.f2er.com/swift/319785.html

猜你在找的Swift相关文章