How do we use Watchkit Touch Events? - ios

I wanna use touch events in my app. I know gesture recognisers can not be used in watchKit. Is it possible to use functions like touchesBegan, touchesMove etc ?

Apple Watch app uses WatchKit framework. UIKit events are not applicable here.
Alternate is to use forced touch event which triggers Context Menu (if available)
Instead of just tapping items on the screen, pressing the screen with a small amount of force activates the context menu (if any) associated with the current interface controller.

There is no such an api like "touchesBegan" or "touchesMove".
The only thing you can do to respond to a button event is to use IBAction.

A little late to the party, but it's possible to use SceneKit with WatchKit and SceneKit allows you to add gesture handlers. Please see the Apple example project here:
https://developer.apple.com/library/content/samplecode/WatchPuzzle/Introduction/Intro.html#//apple_ref/doc/uid/TP40017284-Intro-DontLinkElementID_2
Edit: Looks like Tap, Swipe, Long Press and Pan gesture handles can be added to any view added to the InterfaceController.

Related

Register multi-touch as a single touch?

Is there a way to register multi-touch as a single touch? Say if I use three fingers to tap a large button, can it be registered as simply one tap of the button? -- the current default appears to treat it as a multi-touch, and as a result ignores the button-pressing altogether. Similarly, if I use my palm to tap a large button, the button isn't pressed either.
I noticed in iphone Accessibility Settings -> Touch Accommodations, one could set "Ignore Repeat" and "Use Initial Touch Location" for tap assistance. Of course, if those are turned on, it affects the entire phone instead of just one app. But would that be the direction to approach this problem?
BTW I don't actually need multi-touch in my app. So if turning off multi-touch can be more simply done on the whole-app level instead of button-by-button, it would suit this case very well.
Thank you #DonMag for providing a hint.
So, if yours is an ios app from Capacitor, here is how to change your javascript code:
Change your button onClick events into "onTouchStart"
Use a state variable to keep track of whether "onTouchStart" is triggered and the resulting logic is executing. During that execution, prevent more touch events to have further effect on the button. This is to prevent the button from being pressed in quick succession by multiple touches that come from, say, your three-finger tap or palm tap. Only after the execution is finished do you revert the state variable back to the original value, so that the button is ready to be pressed again.
If there is an answer that's more suitable for the native Swift bundle I'll accept that as the answer. The above is just to help anyone who may encounter the same problem as mine.

IOS notification content extension: add buttons in storyboard and handle the click action

IOS notification content extension: add buttons in MainInterface.storyboard and handle the click action without dismissing the notification
after making some research I discover that:
can not handle buttons clicks in the IOS notification content extension, only the type of button can be used is the media button, see the IOS documentation:
https://developer.apple.com/documentation/usernotificationsui/unnotificationcontentextension
The up answer is not correct, you can just add UNNotificationExtensionUserInteractionEnabled YES to the info.plist, then you can do every thing just like a common viewController
As Abdullah S. Al-Hallak said, it is not possible to perform actions that will lunch a certain screen. In Apple documentation, it is mentioned that "Do not install gesture recognizers or rely on touch events in your interface."
The only possible way is to add actions that will do some things in the presented notification only (like animation, as presented in this cool post: Adding a Custom UI and Interactivity in Local and Push Notifications)

How to childproof an iOS app by requiring "exit" button to be pushed multiple times before exit

I'm quite new to xCode and am trying to build a simple children's app. I have a young child and have experience with her playing with some apps where it's too easy to exit the screen - either with the main iPhone button or by swiping/pushing a button to exit the app. I know there are workarounds to this through the settings on iPhone, however I want to make my app so it is more childproof upfront with regards to exiting the app too easily.
My app is structured with a main menu for parents to access the settings/help and has a play button to enter the kids zone. Once the play button is pressed, a new view controller comes up which is where I'd like to add the code to press the exit button multiple times in a row to get back to the main menu and to disable the iPhone's main button from exiting the app.
If anyone has a suggestion on how to go about this I'd sure appreciate your help!
Cool concept! I'll suggest you use a UITapGestureRecognizer. Many subclasses of UIView accept gesture recognizers so you could simply do the following:
let tap = UITapGestureRecognizer(target: self, action: #selector(theMethodToExit))
tap.numberOfTapsRequired = 4
self.theTappingButton.addGestureRecognizer(tap)
where theMethodToExit is the method you will call to exit from the app and theTappingButton is the UIView or UIView subclass.
I'm not sure if you can attach a gesture recognizer to a UIButton, but it might be worth trying. If not, you can mimic the the behavior of a UIButton with a UIView.
Unfortunately you won't be able to disable the home button from being pressed, though you can provide a tutorial to parents for how to lock the app on the screen.

LongPressGestureRecognizer in watchkit

I am trying to do some action when I long press the button in watchkit.
How can I use long press gesture in Watchkit for WKInterfaceButton?
So far WatchKit doesn't have gesture recognizers. The only way you can use the force touch (the long press in the watch) is using a context menu.
Apple introduced long press gesture recognizers in watchOS3, have a look at the official documentation.

iOS jailbroken device: intercept and block the swipe from down gesture to call the Control Center

What I need is to intercept and block the swipe from down gesture to call the Control Center while the user is using an app (he isn't in the springboard) to replace them with a new action. When the user is in the springboard everything it must be as default so he must be able to open the control center.
What's method I must hook to intercept the control center call under my condition (the user is not in the springboard)?
Thanks
From browsing iOS 6 headers, it seems SBPanGestureRecognizer inherits from SBGestureRecognizer. SBGestureRecognizer has these methods:
- (void)touchesEnded:(struct __SBGestureContext *)arg1;
- (void)touchesMoved:(struct __SBGestureContext *)arg1;
- (void)touchesBegan:(struct __SBGestureContext *)arg1;
I'd look into hooking one of those.

Resources