我希望实现类似iOS 7中的后退手势。我对整个iOS开发还很陌生,目前正在使用以下方法。
目前我有一个平移手势来检测用户是否向后滑动,然后它只是弹出导航控制器。
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];
}
}
我希望在手势拖动时,前一个视图能够跟随手指移动而不是直接调用弹出到根视图的功能。例如,
UINavigationController
实现此功能。你需要自己开发一个控制器导航系统(这是一个过于广泛的主题,无法在单个 stack overflow 问题中回答)。 - borrrden