Force touch with tvOS

Does anyone know how to detect a forced click / click on a remote control using tvOS?

I want to use a click in the Sprite Kit scene to open a "paused action". I do not have UIKit controls that have focus and will respond to a click.

I already use the “normal” touch events on the remote control to move the sprites.

+3
source share
1 answer

Apple suggests using UIPressesEventclick / click detection.

override func pressesBegan(presses: Set<UIPress>, withEvent event: UIPressesEvent?) {
    for item in presses {
        if item.type == .Select {
            self.view.backgroundColor = UIColor.greenColor()
        }
    }
}

override func pressesEnded(presses: Set<UIPress>, withEvent event: UIPressesEvent?) {
    for item in presses {
        if item.type == .Select {
            self.view.backgroundColor = UIColor.whiteColor()
        }
    }
}

override func pressesChanged(presses: Set<UIPress>, withEvent event: UIPressesEvent?) {
    // ignored
}

override func pressesCancelled(presses: Set<UIPress>, withEvent event: UIPressesEvent?) {
    for item in presses {
        if item.type == .Select {
            self.view.backgroundColor = UIColor.whiteColor()
        }
    }
}
+2
source

Source: https://habr.com/ru/post/1615245/


All Articles