侧边栏壁纸
博主头像
Gstory's Blog博主等级

每天进步一点点!

  • 累计撰写 108 篇文章
  • 累计创建 23 个标签
  • 累计收到 11 条评论

目 录CONTENT

文章目录

Flutter跳转iOS原生页面后的穿透问题

gstory
2020-10-21 / 0 评论 / 0 点赞 / 258 阅读 / 1464 字 / 正在检测是否收录...
温馨提示:
本文最后更新于 2023-10-08,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

在插件开发过程中发现flutter页面通过present跳转原生页面后,原生页面上的点击响应下面的Flutter页面中的点击事件。这个问题出现很早了,github中有人提了issue但是一直没有修复。

解决方案:

1.重写从FlutterViewController呈现的UIViewController的4个方法

这可以防止将未处理的事件传播到 FlutterViewController

Swift

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
}

override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
}

override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
}

override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
}

Objective-C

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
}

-(void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
}

-(void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
}

-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
}

2. 停止从 FlutterViewController 做 Present

页面跳转时切换window的根控制器到原生控制器即可,在返回时再切换回flutter中。

0

评论区