我使用以下代码
[self.navigationController.interactivePopGestureRecognizer addTarget:self action:@selector(handlePopGesture:)];
- (void)handlePopGesture:(UIGestureRecognizer *)gesture {
if (gesture.state == UIGestureRecognizerStateBegan)
{
} else if (gesture.state == UIGestureRecognizerStateEnded) {
NSArray *views = [self.navigationController viewControllers];
[self.navigationController popToViewController:[views objectAtIndex:1] animated:YES];
}
但它没有解决如何使用interactivePopGestureRecognizer弹出视图控制器的问题?
答案 0 :(得分:0)
确保您的.h文件是委托。
@interface YOURVIEWCONTROLLER : UIViewController <UIGestureRecognizerDelegate>
在你的.m include
中self.navigationController.interactivePopGestureRecognizer.delegate = self;
然后你的委托方法应该识别你的手势。