IOS creates wipes for return

I want to make the back, as in iOS 7. I'm still new to all iOS development, this is what I'm using right now.
I currently have a panorama gesture that detects that the user is bouncing back and then just pops the navigation controller.

UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)]; [self.view addGestureRecognizer:pan]; -(void)handlePan:(UIPanGestureRecognizer *)sender{ CGPoint tran = [recognizer translationInView:recognizer.view]; CGPoint vel = [recognizer velocityInView:recognizer.view]; if(vel.x > 500 && tran.x > 100){ [self.navigationController popViewControllerAnimated:YES]; } } 

I want the previous view to follow a finger on the panorama gesture instead of just calling pop for root. For instance,

SecondviewSwiping between the viewsFirstview

+4
source share
3 answers

This will require a custom container view controller. Simply put, you have a view controller that contains 2 view controllers (view 1 on the left and view 2 on the right).

You attach a panorama gesture to the container view, and when the user moves, you calculate the corresponding frame for each of the subview controllers. For instance. if the user pans to the right, you move view 2 to the right and bring view 1 to the left (by calling the controller methods of the child view as necessary).

When the gesture ends, you must check the end position in combination with the final pan direction to decide where you should place the view controllers. for example, if you finish panning on the right 90% of view 1 on the screen, you must completely move view 1 on the screen and view 2 screens. if you're done with 50% of each, you should use the pan direction to decide which view will remain on the screen.

+9
source

Use IIViewDeckController is easier and it does what you want IIViewDeck GitHub

+1
source

I think that in this case you should use UIScrollView, set the size of the contents of your scroll view for width_of_view * numberOfViews and add your entire view to the horizontal scroll view. when the user scrolls or scrolls with their finger on the screen, which shows the following view. here the link to the apple document will help you. Remember to set the horizontal scroll resolution in XIB or in code.

0
source

Source: https://habr.com/ru/post/1490651/


All Articles