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;
    }
}

 上面问题解决后,就会导致新的问题出现,flutter1级页面无法 手势滑动pop回原生。

在flutter1级页面加了自定义手势,给原生发channel消息,原生pop回上一级页面,这种解决方案,滑动手势不优雅,滑动体验卡顿。有没有更好的解决方案呢?

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