Each UIViewController, starting with rootViewController uses [self.navigationController pushViewController nextView] to push 开发者_开发问答new views. Swipe works fine.
How can I implement the same behavior for the swipe forward? I more exactly, how I keep the UIViewController after popped with swipe back or back button, so I can add it again in case of swipe forward?
To keep track of your view controllers, you could do the following:
Add an instance variable (as a strong property)
nextViewControllerto all your view controllersWhenever you push a new view controller, set
nextViewControllerto the pushed view controllerNow, whenever the user swipes forward, you just push the
nextViewController. But, first check fornil. IfcurrentViewController.nextViewController = nilyou know that the user has never navigated beyond this point, and you handle appropriately. You could just ignore the swipe forward, or you could send the user a message.
To handle the swipe itself:
Just add a UISwipeGestureRecognizer to each view controller's
view.Then, when your swipe method is called, check the gesture recognizer's
directionproperty. If it was a forward swipe, push thenextViewControlleras described above.
加载中,请稍侯......
精彩评论