touch-up-inside

iOS/Swift: how to detect touch action on a UITextField

给你一囗甜甜゛ 提交于 2020-05-25 03:23:07
问题 I would like to detect the touch action on a UITextField. It seems the "Touch Up Inside" action is not fired by touching inside the textfield. 回答1: It seems "Touch Up Inside" is not enabled for UITextField , but "Touch Down" works. So the solution is as follows: Swift 4.x myTextField.addTarget(self, action: #selector(myTargetFunction), for: .touchDown) @objc func myTargetFunction(textField: UITextField) { print("myTargetFunction") } Swift 3.x myTextField.addTarget(self, action: #selector

UIButton Highlighted State not showing when clicking over a Selected UIButton

放肆的年华 提交于 2019-12-12 08:34:40
问题 I want my UIButton to show up the highlighted state when I click over a button that is already selected. Basically in the highlighted state I apply a *.png image as my UIButton backgroundImage to give a pressed down effect. But if the button is already in the Selected State When I click over it again I just can't see the highlighted state but it goes straight to the normal state! Watch the Issue--> Video of the Issue! Help please //0 init UIButton UIButton *button = [[UIButton alloc]

UIButton Highlighted State not showing when clicking over a Selected UIButton

心已入冬 提交于 2019-12-04 05:04:49
I want my UIButton to show up the highlighted state when I click over a button that is already selected. Basically in the highlighted state I apply a *.png image as my UIButton backgroundImage to give a pressed down effect. But if the button is already in the Selected State When I click over it again I just can't see the highlighted state but it goes straight to the normal state! Watch the Issue--> Video of the Issue! Help please //0 init UIButton UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(x, y, aSide, aSide)]; //1 Give it a backgroundColor [button setBackgroundColor:aColor]