84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
在网易新闻客户端中,具体一篇新闻里,用手势右滑,返回列表,左滑出现评论页,顶部的 navigation也能跟着一起动,这种效果怎么实现的,有具体实例更好,求教
学习是最好的投资!
Let me talk about how to implement this on iOS.
Generally, this kind of app uses a navigation controller, uses a tableview to display a list of news titles, and clicks to display the news text.
Your question is how to implement left and right swiping, such as in the view of the news text Add
//........towards right Gesture recogniser for swiping.....// UISwipeGestureRecognizer *rightRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipeHandle:)]; rightRecognizer.direction = UISwipeGestureRecognizerDirectionRight; [rightRecognizer setNumberOfTouchesRequired:1]; [self.view addGestureRecognizer:rightRecognizer]; //[rightRecognizer release]; //........towards left Gesture recogniser for swiping.....// UISwipeGestureRecognizer *leftRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipeHandle:)]; leftRecognizer.direction = UISwipeGestureRecognizerDirectionLeft; [leftRecognizer setNumberOfTouchesRequired:1]; [self.view addGestureRecognizer:leftRecognizer]; //[leftRecognizer release]; [self.navigationController setNavigationBarHidden:YES animated:YES];
Then you can define the implementation of left and right sliding (implemented with segue in iOS)
- (void)rightSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer { [self.navigationController popViewControllerAnimated:YES]; } - (void)leftSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer { [self performSegueWithIdentifier:@"forward" sender:self]; }
This is a thumbnail of the storyboard, you can clearly see the logic of the entire app.
I wrote out the prototype by the way. The source code is here. Please look at the source code carefully. I hope it will be helpful to you.
Let me talk about how to implement this on iOS.
Generally, this kind of app uses a navigation controller, uses a tableview to display a list of news titles, and clicks to display the news text.
Your question is how to implement left and right swiping, such as in the view of the news text
in viewDidLoadAdd
Then you can define the implementation of left and right sliding (implemented with segue in iOS)
This is a thumbnail of the storyboard, you can clearly see the logic of the entire app.
I wrote out the prototype by the way. The source code is here. Please look at the source code carefully. I hope it will be helpful to you.