Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect button being tapped - iOS

I'm working with objective-c and I want to detect when the user is tapping a button (not when he tapped it, but the actual moment when is being taped until he stops). Is there any method? I'm not finding it if there's any. Thanks

like image 505
Jaime Alcántara Arnela Avatar asked Jun 01 '26 16:06

Jaime Alcántara Arnela


1 Answers

Using touchDown event you can make an action while your button is pressed

enter image description here

Example

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var label: UILabel!
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    @IBAction func testing(_ sender: Any) {
        label.textColor = UIColor.red
    }

    @IBAction func testingCancel(_ sender: Any) {
        label.textColor = UIColor.black
    }

    @IBAction func testingUpInside(_ sender: Any) {
        label.textColor = UIColor.black
    }


}
like image 169
Reinier Melian Avatar answered Jun 03 '26 07:06

Reinier Melian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!