これを使いました。
self.navigationController.interactivePopGestureRecognizer.delegate = self;
また、UINavigationController クラスで、遷移中に interactivePopGestureRecognizer を無効にします。
- (void)pushViewController:(UIViewController *)viewController
animated:(BOOL)animated
{
if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.interactivePopGestureRecognizer.enabled = NO;
}
[super pushViewController:viewController animated:animated];
}
- (void)navigationController:(UINavigationController *)navigationController
didShowViewController:(UIViewController *)viewController
animated:(BOOL)animated
{
if ([navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
// disable interactivePopGestureRecognizer in the rootViewController of navigationController
if ([[navigationController.viewControllers firstObject] isEqual:viewController]) {
navigationController.interactivePopGestureRecognizer.enabled = NO;
} else {
// enable interactivePopGestureRecognizer
navigationController.interactivePopGestureRecognizer.enabled = YES;
}
}
}
rootViewController で interactivePopGestureRecognizer を無効にする理由は次のとおりです。rootViewController の端からスワイプしてから何かをタップして次の viewController にプッシュすると、UI は現在タッチを受け付けません。ホーム ボタンを押してアプリをバックグラウンドにし、タップして入力します。前景...