如何在Swift中单击UILabel时显示键盘显示



我试图在使用NotificationCenter按下UILabel时显示键盘,但键盘功能没有调用也没有显示键盘,我真的需要在Swift中按下UILabel的时候显示键盘。

在我的班级

MyClass : UIControl {} 

但是键盘功能没有调用

private func _ini(){ let notificationCenter = NotificationCenter.default notificationCenter.addObserver(self, selector: #selector(KeyboardDidShow(_:)), name: UIResponder.keyboardDidShowNotification, object: nil) } 
func KeyboardDidShow( myNotification: NSNotification){
print("keyBoardUp") 
}

键盘只显示接受输入的视图,如UITextFieldUITextview等,或确认遵循UIKeyInput协议并实现canBecomeFirstResponder的视图

最新更新