flutter右滑返回直接返回到native问题

iOS跳flutterViewController后,flutter1又跳了flutter2,flutter2侧滑返回总是返回到原生,期望侧滑返回到flutter1页面。

解决方案:

在iOS原生导航类 BaseNavigationController 中,修改下面代理方法,如果是flutter类,就禁用了iOS原生手势。这样flutter的侧滑手势优先级就上来了。

 - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
    if ([viewController isKindOfClass:[FlutterViewController class]]) {
        self.interactivePopGestureRecognizer.enabled = NO;
    } else {
        self.interactivePopGestureRecognizer.enabled = YES;
    }
}

 

posted @ 2025-09-10 17:21  黄增松  阅读(29)  评论(0)    收藏  举报