Dragging Gestures in iOS 8 Today Extensions
Asked Answered
D

3

9

I'm using a UIView subclass in my Today widget. The view makes use of swiping gestures. However, these gestures either scroll the whole Notification Center up and down, or make the Notification Center switch from Today to Notifications.

Is there any way to prevent the touch events to be bubbled up to the Notification Center scroll view? Using [self setExclusiveTouch:YES]; in the subclass did not solve it unfortunately.

Disentangle answered 3/7, 2014 at 21:20 Comment(2)
I'm having the same issue. I also tried to use [self setExclusiveTouch:YES] but it didn't work.Alkaline
I have the similar issue. I need to detect touchMoves on my view. Horizontal move is ok. But Vertical move makes the whole Today view scroll. :-(Angadresma
W
4

Is there any way to prevent the touch events to be bubbled up to the Notification Center scroll view? Using [self setExclusiveTouch:YES]; in the subclass did not solve it unfortunately.

No. Because of the remote view hosting that your Today widget is being presented inside, [self setExclusiveTouch:YES] doesn't quite do what you want.

The rough architecture in iOS 8.0 is:

[User touch creates a UITouch]
            |
            v
Notification Center (UIScrollView)
            |
            v
  UIRemoteView container
  (presents your UIView)
[crosses process boundary]
            |
            v
your Today widget's UIView

Think of the touch as basically becoming cloned when it crosses the process boundary. Your view's exclusive touch desires are only relevant in your widget's process space/window, and don't propagate back outwards to the Notification Center which is hosting you remotely.

Walker answered 17/10, 2014 at 22:53 Comment(0)
E
3

Apples official advise as mentioned in another answer:

Avoid putting a scroll view inside a widget. It’s difficult for users to scroll within a widget without inadvertently scrolling the Today view.

This is pretty poorly written advice from Apple. It is perfectly fine to use a scroll view in a Today widget but you must disable scrolling so that it doesn't interfere. Apple even use a UITableView in their WWDC talk.

Basically it advises you not to interfere with the Notification Centers existing gestures.
The existing gestures happen to be scrolling in all four directions so you are pretty limited on what you can do with gestures in a widget.

What sort of gesture are you trying to achieve? You mentioned swiping but if you do that you're going to interfere with the existing gestures and break things. This sort of behaviour wouldn't be allowed in a widget as it would effect the UX of the operating system itself.

Maybe you should look into taking a different approach to handle your action?

Equilibrium answered 14/7, 2014 at 10:3 Comment(5)
The question is, without swiping gestures, what else can you do? Only tapping, and this is quite limiting.Gaye
@LimThyeChean The main purpose of the Today View is to provide information that can be quickly accessed eliminating the need to enter the application itself. If you then go an make a complex UX what involves swiping to reveal content or to perform actions etc then you are using the Today view to extend too much functionality of your application taking the focus away from what the Today View was designed to do.Equilibrium
Kind of agreed. But having swipe gestures can makes a lot of better simple UI. A simple example, since the screen estate is small, I would like to use left and right gesture to choose previous and next item. Without swipe gesture, then all I can do is to either show 1 item, or back to the back/next arrow days.Gaye
@LimThyeChean You do have a point there however as I previously mentioned, by adding your swipe gesture to your widget, you would be hijacking the interaction in the Notification Centre (swiping left and right to switch between the Today View and the Notifications View). I can only imagine that Apple don't want you doing this as it would effect the UX of the OS (rather than just a specific third party app).Equilibrium
This I agreed. I am just thinking that this mean we won't be seeing too many interesting widgets when all you can do is tap.Gaye
U
1

According to Apple's App Extensions Programming Guide:

"Avoid putting a scroll view inside a widget. It’s difficult for users to scroll within a widget without inadvertently scrolling the Today view."

Unideaed answered 10/7, 2014 at 23:53 Comment(2)
I am not putting a scroll view in the widget. I'm talking about a UIView with custom touch handling.Disentangle
@Disentangle I believe the reason they mention this is because the swiping gesture interferes with the swiping gesture used to scroll the today view... Regardless of if that swipe is in a scroll view or an actual UISwipeGestureRecognizerDobla

© 2022 - 2024 — McMap. All rights reserved.