songxiaoliang / react-native-baidu-face

基于百度人脸识别封装的react-native模块,支持Android、iOS平台设备
95 stars 28 forks source link

ios=>当多个页面集成了人脸活体检测功能,有的页面调不起来人脸识别的页面。 #2

Open ZhangTaoK opened 5 years ago

ZhangTaoK commented 5 years ago

xcode 报错误警告

which is already presenting...

导致FaceCheckHelper.openPushFaceViewController(obj);调不起来原生人脸识别的页面。

因为: popover中的控制器, 其实是通过窗口的根控制器presenting出来的, 所以要想窗口的根控制器再presenting其他控制器,需要先dismiss掉原来presenting的控制器

解决方案: 在xcode中打开PushFaceViewControllerModule.m

找到以下代码: UINavigationController nav = [[UINavigationController alloc] initWithRootViewController:lvc]; nav.navigationBarHidden = true; AppDelegate app = (AppDelegate *)[[UIApplication sharedApplication] delegate]; [app.window.rootViewController presentViewController:nav animated:YES completion:nil];

修改为以下代码: UINavigationController nav = [[UINavigationController alloc] initWithRootViewController:lvc]; nav.navigationBarHidden = true; AppDelegate app = (AppDelegate *)[[UIApplication sharedApplication] delegate]; [app.window.rootViewController dismissViewControllerAnimated:YES completion:nil]; [app.window.rootViewController presentViewController:nav animated:YES completion:nil];

在presentViewController之前加入dismiss的方法就可以了。

加入代码:[app.window.rootViewController dismissViewControllerAnimated:YES completion:nil];

如果有更好的方法,请留言。

songxiaoliang commented 5 years ago

@ZhangTaoK 已将pr建议采纳,合并master。