草庐IT

SELECTOR

全部标签

ios - NSNotificationCenter Swift 3.0 在键盘上的显示和隐藏

我正在尝试在键盘显示和消失时运行一个函数,并具有以下代码:letnotificationCenter=NotificationCenter.defaultnotificationCenter.addObserver(self,selector:#selector(ViewController.keyBoardUp(Notification:)),name:NSNotification.Name.UIKeyboardWillShow,object:nil)和下面的函数keyBoardUp:funckeyBoardUp(Notification:NSNotification){print(

ios - NSNotificationCenter Swift 3.0 在键盘上的显示和隐藏

我正在尝试在键盘显示和消失时运行一个函数,并具有以下代码:letnotificationCenter=NotificationCenter.defaultnotificationCenter.addObserver(self,selector:#selector(ViewController.keyBoardUp(Notification:)),name:NSNotification.Name.UIKeyboardWillShow,object:nil)和下面的函数keyBoardUp:funckeyBoardUp(Notification:NSNotification){print(

swift - 关于 Swift 选择器的 4 个问题

抱歉这些问题我有4个关于swift中的选择器的问题。第一个问题我想知道在swift中使用选择器的正确方法是什么closeBarButtonItem=UIBarButtonItem(barButtonSystemItem:UIBarButtonSystemItem.Stop,target:self,action:Selector("closeBarButtonItemClicked:"));对比closeBarButtonItem=UIBarButtonItem(barButtonSystemItem:UIBarButtonSystemItem.Stop,target:self,acti

swift - 关于 Swift 选择器的 4 个问题

抱歉这些问题我有4个关于swift中的选择器的问题。第一个问题我想知道在swift中使用选择器的正确方法是什么closeBarButtonItem=UIBarButtonItem(barButtonSystemItem:UIBarButtonSystemItem.Stop,target:self,action:Selector("closeBarButtonItemClicked:"));对比closeBarButtonItem=UIBarButtonItem(barButtonSystemItem:UIBarButtonSystemItem.Stop,target:self,acti

ios - 如何在 Swift 3 中编写键盘通知

我正在尝试将此代码更新为swift3:NSNotificationCenter.defaultCenter().addObserver(self,selector:Selector("keyboardWillShow:"),name:UIKeyboardWillShowNotification,object:nil)NSNotificationCenter.defaultCenter().addObserver(self,selector:Selector("keyboardWillHide:"),name:UIKeyboardWillHideNotification,object:n

ios - 如何在 Swift 3 中编写键盘通知

我正在尝试将此代码更新为swift3:NSNotificationCenter.defaultCenter().addObserver(self,selector:Selector("keyboardWillShow:"),name:UIKeyboardWillShowNotification,object:nil)NSNotificationCenter.defaultCenter().addObserver(self,selector:Selector("keyboardWillHide:"),name:UIKeyboardWillHideNotification,object:n

swift - 我可以让#selector 引用 Swift 中的闭包吗?

我想让我的方法的一个selector参数引用一个闭包属性,它们都存在于同一个范围内。例如,funcbackgroundChange(){self.view.backgroundColor=UIColor.blackColor()self.view.alpha=0.55letbackToOriginalBackground={self.view.backgroundColor=UIColor.whiteColor()self.view.alpha=1.0}NSTimer.scheduledTimerWithTimeInterval(0.5,target:self,selector:#se

swift - 我可以让#selector 引用 Swift 中的闭包吗?

我想让我的方法的一个selector参数引用一个闭包属性,它们都存在于同一个范围内。例如,funcbackgroundChange(){self.view.backgroundColor=UIColor.blackColor()self.view.alpha=0.55letbackToOriginalBackground={self.view.backgroundColor=UIColor.whiteColor()self.view.alpha=1.0}NSTimer.scheduledTimerWithTimeInterval(0.5,target:self,selector:#se

ios - '#selector' 的参数不引用 '@objc' 方法、属性或初始值设定项

我在Swift3中继承了一个用Objective-C编写的UIButton子类。当我尝试添加目标时,它失败并显示错误代码:classActionButton:JTImageButton{funcaction(){}funcconfigure()){//...self.addTarget(self,action:#selector(self.action()),for:.touchUpInside)//error://Argumentof'#selector'doesnotrefertoan'@objc'method,property,orinitializer}}

ios - '#selector' 的参数不引用 '@objc' 方法、属性或初始值设定项

我在Swift3中继承了一个用Objective-C编写的UIButton子类。当我尝试添加目标时,它失败并显示错误代码:classActionButton:JTImageButton{funcaction(){}funcconfigure()){//...self.addTarget(self,action:#selector(self.action()),for:.touchUpInside)//error://Argumentof'#selector'doesnotrefertoan'@objc'method,property,orinitializer}}