简体   繁体   English

呈现视图 controller 位于呈现视图 controller 下方

[英]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.

相关问题 如何在呈现的View Controller和呈现的View Controller之间建立关系? - How to setup a relationship between the presenting View Controller and the presented View Controller? 使用CAShapeLayer遮罩呈现的视图控制器,也遮罩呈现的视图控制器 - masking presented view controller with CAShapeLayer also mask the presenting view controller 如何暂时隐藏同时呈现视图控制器的呈现视图控制器 - How to temporarily hide a presented View controller that is also presenting a view controller 呈现视图 controller 也可以是呈现视图 controller 吗? - Can a presented view controller also be a presenting view controller? 呈现的视图控制器隐藏在导航控制器下 - Presented view controller hidden under navigation controller 呈现视图控制器将显示其下的导航控制器 - Presenting a view controller shows navigation controller under it 旋转呈现的视图并锁定呈现视图控制器的方向 - Rotate presented view and lock the orientation of presenting view controller 为什么模式视图(由详细视图控制器呈现)呈现视图控制器是拆分视图控制器? - Why modal view's (presented by detail view controller) presenting view controller is split view controller? 调用viewWillAppear时显示视图控制器的问题被解除 - Issue with calling viewWillAppear of presenting view controller when presented one is dismissed 消除演示的VC时,Presenting View Controller失去子视图 - Presenting View Controller loses subviews when dismissing presented VC
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM