how to add page switching animation effect in different content of 1 UIViewController?
-
14-10-2019 - |
Question
I have an UIViewController on showing my friends' data. This controller supports swipe gesture: swipe the screen left will transfer to next friend's data, to right back to previous. so it is only 1 UIViewController, the whole process just reloads new data and refreshes UI when different content reading from server api returns.
is it possible that adding a page switch effect in swipe and content change, like they are in different UIViewController? my code is basically like this structure,
1.[passing friend id, get server api return]; 2.[parsing it and populate content on UI]; 3.[swipe detect]; 4.[reload data by passing a new friend id then repeat 1-4];
Thanks in advance!
Solution
I suggest you use this structure: 1 parent controller, 2 children controllers. Whenever a turn-the-page action is triggered, the parent dismisses the current child and presents the other.
In this way you can implement the turn-the-page animation with ease, with the UIViewAnimationTransitionCurlUp system animation effect.