使用现在和全屏
我正在使用.present
呈现视图。 当应用程序加载时,第一个视图是登录图,该视图是从MainView加载的,该视图是顶部控制器的MainView。
所有视图均以专用方法呈现。我可以清楚地看到,目前尚无其他观点。
我不希望视图被轻扫不可忽视。为此,我使用.fullscreen
。当我使用全屏时,我会看到错误/警告“ 不平衡的调用开始/结束外观过渡”。使用“全屏”,在演示文稿完成后,将删除属于呈现视图控制器的视图。我怀疑这是消息的原因。
如果我使用.overfullscreen
我看不到此消息。使用.overfullscreen
在演示文稿结束时,所呈现内容下方的视图不会从视图层次结构中删除。
任何人都可以确认在FullScreen
过渡之后删除视图的内置动作是此消息的原因,以及我如何在不触发此消息的情况下使用FullScreen
。
使用Swift 5和Xcode 13.4.1,Mac OS 12.2.1
func presentView(viewInstance: UIViewController){
if let topController = UIApplication.topViewController() {
viewInstance.modalPresentationStyle = . fullScreen
topController.present(viewInstance, animated: false, completion: nil)
}
}
extension UIApplication {
class func topViewController(controller: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController? {
if let navigationController = controller as? UINavigationController {
return topViewController(controller: navigationController.visibleViewController)
}
if let tabController = controller as? UITabBarController {
if let selected = tabController.selectedViewController {
return topViewController(controller: selected)
}
}
if let presented = controller?.presentedViewController {
return topViewController(controller: presented)
}
return controller
}
}
I am presenting views with .present
.
When the app loads the first view is loginView which is loaded from mainView which is the top controller.
All views are presented in a dedicated method. I can see clearly that at this time no other views are being presented.
I do not want views to be dismissible with a swipe. To achieve this I am using .fullScreen
. When I use full screen I see the error/warning "unbalanced calls to begin/end appearance transitions". Using 'fullScreen' the views belonging to the presenting view controller are removed after the presentation completes. I suspect that this is the cause of the message.
If I use .overFullScreen
I do not see this message. Using .overFullScreen
the views beneath the presented content are not removed from the view hierarchy when the presentation finishes.
Can anyone confirm that built in action of removing views following the fullScreen
transition are the cause of this message and how can I use fullScreen
without triggering this message.
Using Swift 5 and Xcode 13.4.1, Mac OS 12.2.1
func presentView(viewInstance: UIViewController){
if let topController = UIApplication.topViewController() {
viewInstance.modalPresentationStyle = . fullScreen
topController.present(viewInstance, animated: false, completion: nil)
}
}
extension UIApplication {
class func topViewController(controller: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController? {
if let navigationController = controller as? UINavigationController {
return topViewController(controller: navigationController.visibleViewController)
}
if let tabController = controller as? UITabBarController {
if let selected = tabController.selectedViewController {
return topViewController(controller: selected)
}
}
if let presented = controller?.presentedViewController {
return topViewController(controller: presented)
}
return controller
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论