How can I implement a circular scrolling mechanism?

I have some images from which the user has to select one. Now, I don't want to just offer a flat scrolling area with a boring grid. Instead, I would like to show a wheel containing these images. There will be a marker at the top indicating the selection. Something similar to collectors.

Rotation is not the problem; I would use some geometric functions for this. But I have no idea how to actually get the scrolling gestures on this wheel. Where to begin?

By the way: with circular, I don't mean something like Pickers. I mean a real wheel that has a center axis and can be folded. Like old phones, like a bicycle wheel. Or the Picker is rotated 90 ° facing the axis towards you (Z-coordinate).

+1


a source to share


2 answers


If you are talking about gesture capture then here is an example they give in the docs .

While I could swear that I heard Alan Cannistraro say in one of the first lectures of CS193P that you don't have to do this, that you can just grab the swipe event, but I can't find it.



Maybe someone who really knows what they are doing correct me and I will delete this post, but for now I know this will work:

#define HORIZ_SWIPE_DRAG_MIN  12
#define VERT_SWIPE_DRAG_MAX    4

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    startTouchPosition = [touch locationInView:self];
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint currentTouchPosition = [touch locationInView:self];

    // If the swipe tracks correctly.
    if (fabsf(startTouchPosition.x - currentTouchPosition.x) >= HORIZ_SWIPE_DRAG_MIN &&
        fabsf(startTouchPosition.y - currentTouchPosition.y) <= VERT_SWIPE_DRAG_MAX)
    {
        // It appears to be a swipe.
        if (startTouchPosition.x < currentTouchPosition.x)
            [self myProcessRightSwipe:touches withEvent:event];
        else
            [self myProcessLeftSwipe:touches withEvent:event];
    }
    else
    {
        // Process a non-swipe event.
    }
}

      

+1


a source


How do you think about how similar the electors are? You can load the fit view using your own custom subzones, which can be images. This will give you a real picker with your images, which may or may not be what you are actually targeting.



0


a source







All Articles