Swipe left/right to push next/previous details view
Posted
by
Youssef
on Stack Overflow
See other posts from Stack Overflow
or by Youssef
Published on 2013-07-02T09:34:31Z
Indexed on
2013/07/02
11:05 UTC
Read the original article
Hit count: 283
I am working on a ios application, using storyboard.
I have a simple table view with rows. Each row has a "key" string to identify it. When the user clicks on a row I push the next view "DetailsViewController" and pass the "key" as a parameter in the prepareForSegue
method. The data in the second view will change based on the "key" passed.
In the "DetailsViewController" I want to add a swipe gesture, when the user swipes right, I want to push the next details view. It will be as if he clicked on the next row in the table view. So to rephrase, the user has 2 ways of switching between items: he can click the item in the table view and the details view will show, he can then go back and select another item.
Or he can click on a row, and in the details view he can swipe left and right to see the previous/next item.
i added the uigesture recognizer:
UISwipeGestureRecognizer *recognizer;
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];
[recognizer setDirection:UISwipeGestureRecognizerDirectionRight];
[[self view] addGestureRecognizer:recognizer];
- (void) handleSwipe:(UISwipeGestureRecognizer *) sender
{
//I want to go to the next item in the tableview
}
I hope I was clear.
Thank you.
© Stack Overflow or respective owner