I added the SwipeGesture to a View on my Page. If i make a Left Swipe the View switches to another Subview. Same if you do a right swipe.
The Problem is, that on one of my pages is a UISlider and if you change the value of this, the Swipe Gesture Triggers and Navigates to another Subview.
Is it possible to make a Swipe Gesture which triggers if you swipe with 2 Fingers?
Yes, you can use a swipe gesture with two fingers using the numberOfTouchesRequired property. I agree with #Jonathan.Peppers though that if you have conflicting gesture patterns it's bad UX practice to slightly differentiate them by incrementing the touch points.
I would also recommend using this abstraction for using gestures and modify it using some sort of type check for swipe: https://gist.github.com/1453770
if(typeof(T) == typeof(UISwipeGestureRecognizer)) {
((UISwipeGestureRecognizer)fRecognizer).NumberOfTouchesRequired = 2;
}
Related
I have a game Activity, which contains a SurfaceView that fills the whole screen.
The app is declared as fullscreen, and appears as such.
My SurfaceView has an OnTouchListener, which feeds a GestureDetector, with a functionality that works fine on most devices.
The listener is set as simply as:
surface.setOnTouchListener(listener);
However, on Jelly Bean (Nexus 4) , touching the soft buttons (back, home, etc.) generates a touch event in coordinates that are irrelevant to my SurfaceView.
This currently generates weird behaviors.
I can workaround that by simply doing a check on touch events and see if they fit the surface size.
However, I was wondering if there is a more elegant solution - one that will just give me the touch events ONLY from my surface and not from those soft buttons.
This is also crucial in the case that some future devices do different variations of that (putting the soft buttons in the UPPER area, for example).
As of right now I have a View with a UIWebView inside of it and some added custom gestures. Some examples of these gesture are Two Finger Slide Right to Go Back, Two Finger Slide Left to Go Forward, Two Finger Long Press for Refresh, ect.. But now I'm facing an issue I knew I would have to face when I began developing this app:
All of the gestures work great unless the UIWebView is zoomed in. Even if it is zoomed in the tiniest bit (or you are able to scroll the web page horizontally), the gestures that require you to swipe left or right are suddenly disabled because UIWebView takes first priority over these gestures.
If anyone can shine some light on this issue or even provide a work-around, I would be very grateful. Thanks!
I'm more familiar with OS X, but could you subclass UIWebView to remove this behavior?
I have gotten UIWebView inside UIScrollView to work, so far anyways, and I have just seen mention on Apple's site that doing so is not advised.
So OK, what's the alternative? I need to display web pages, and I need them to be scrollable, such that if the user swipes leftward then an entirely different page appears coming in from the right. And a reverse situation with swiping rightward.
How is that done without putting UIWebView inside UIScrollView?
Thanks.
Well, you need the UIWebView, which has indeed many features of a UIScrollView, to be able to scroll not only up and down, but also to left and right.
Also, scrolling with two fingers is a no-go, for scrollable elements within a web page, such as textareas can only be scrolled with two fingers.
Three fingers is also not so good because that's not convenient for people with thick fingers...
So my suggestion is that you add a UIGestureRecognizer to your UIWebView and look out for a swipe gesture. Then handle the switching of pages accordingly with animations.
this is a very general Question to LWUIT.
I'm developing for Nokia S40 phones.
I'm having a List in a form which functions as a Menu. The Form has an ActionListener which listens to SoftkeyEvents and also the List click events.
It's doing this by e.g.:
if (evt.getCommand() != null) {
if (evt.getCommand().getCommandName().equals("Back")) {
if (Display.getInstance().getCurrent().getUIID().equals("SubMenu")) {
and:
if (Display.getInstance().getCurrent().getUIID().equals("Menu") ) {
The problem is:
the menu seems to be hypersensitive to scrolling but not sensitive enough to clicking.
Means: If you try to click a menu entry in the List, the List very often scrolls instead of actually catching the link.
Is there some way to influence this behaviour?
Updated answer: FYI We had S40 touch phones and our QA didn't report these issues as far as I recall. Keep in mind this is a resistive screen hence it can't handle fingers, it works best with the finger nail and you will get bad results otherwise. With the finger you will get drag events all over the place which is why you are probably experiencing what I explain bellow.
You are probably seeing this because LWUIT received pointerDragged events from the phone and hence made the decision that a drag operation is in progress. There are general rule of thumb values for pointer drag event blocking within LWUIT implementation (to prevent over eager platforms from sending too many drag events). If a platform sends "inappropriate" drag events LWUIT will just drop them to avoid confusing your application.
Display.setDragStartPercentage() allows you to tune the percentage of the screen that the finger needs to move in order to trigger a drag. By default if the system sends 7 drag events we activate the drag regardless, that option is only configurable to the LWUITImplementation authors.
How can I have a layout were when you swipe your finger to the left it goes to another layout or activity?
-EXAMPLE-
{layout 1} {layout 2 (default)}
User SWIPES left
<---
[moves to Layout 1]
Though I think your example is counter-intuitive (I would expect that the User should swipe right to move to layout 1, unless it's cycling through the layouts), there's a few libraries which provide this functionality, most of which based on the Android Homescreen, which uses the idea of workspaces. See this question:
Developing an Android Homescreen