[英]Presented view controller place under presenting view controller
I build a native iOS framework, which imported to a Unity project, to manage game account (login, logout, signup,...).我构建了一个本地 iOS 框架,导入到 Unity 项目中,以管理游戏帐户(登录、注销、注册等)。 When I call framework method to show login screen, it's presented but place under presenting view controller.当我调用框架方法来显示登录屏幕时,它会显示但放在显示视图 controller 下。
- (void)showViewController:(UIViewController *)controller {
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:controller];
nav.navigationBarHidden = YES;
[nav setModalPresentationStyle: UIModalPresentationOverCurrentContext];
[[UIViewController topMostController] presentViewController:nav animated:YES completion: nil];
}
+ (UIViewController*) topMostController {
UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController;
while (topController.presentedViewController) {
topController = topController.presentedViewController;
}
return topController;
}
topMostController return UnityDefaultViewController (it's also rootViewController of keyWindow), and input of showViewController is my SigninViewController, why it's place under UnityDefaultViewController? topMostController返回UnityDefaultViewController(也是keyWindow的rootViewController),showViewController的输入是我的SigninViewController,为什么放在UnityDefaultViewController下面? I have imported this framework to a few Unity game before, but this is the first time I saw this issue.之前在几个Unity游戏中导入过这个框架,但是第一次看到这个问题。
[Update] After review code, there is some line of code which generated by Unity engine (my Unity dev guy said that) cause that issue: [更新] 检查代码后,Unity 引擎生成的一些代码行(我的 Unity 开发人员说的)导致了这个问题:
- (void)showGameUI
{
...
[_window addSubview: _rootView]; //this line cause the issue
_window.rootViewController = _rootController;
[_window bringSubviewToFront: _rootView];
...
}
Can anyone confirm these line of code are generated by Unity engine?谁能确认这行代码是由 Unity 引擎生成的? I have tried to comment that line, issue gone and I haven't found other issue yet, but is that ok?我试图评论那条线,问题消失了,我还没有发现其他问题,但是可以吗?
After many hours, finally I fixed it by changing presentation style from UIModalPresentationOverCurrentContext to UIModalPresentationOverFullScreen.几个小时后,我终于通过将呈现样式从 UIModalPresentationOverCurrentContext 更改为 UIModalPresentationOverFullScreen 来修复它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.