gpt4 book ai didi

ios - 是否可以动态关闭菜单(分屏)

转载 作者:行者123 更新时间:2023-11-29 10:51:17 26 4
gpt4 key购买 nike

我一直在做一个 RubyMotion 项目,我正在使用 UISplitViewController,但我想知道:是否可以通过编程方式关闭侧面屏幕(即隐藏的屏幕)?

我猜这是 iOS 中的私有(private) API,但我不确定或者这是真的。我可以通过点击屏幕上的其他位置来关闭分屏(默认 iOS 行为),但我找不到创建该效果的函数。

我一直在网上搜索这个问题,但找不到这个问题的任何答案。希望你们能帮帮我。

干杯。

最佳答案

为此,您需要使用 UISplitViewController Delegate 并实现 splitViewController:shouldHideViewController:inOrientation:

当按下按钮时,分配的委托(delegate)可以有一个在 true/false 之间改变的属性。

在您的 splitViewController:shouldHideViewController:inOrientation: 中,您将返回该属性以说明是否应显示主视图。

最后,当按钮被按下时,您还需要调用setNeedsLayout 强制重绘并调用委托(delegate)方法。

# Button Touch Handler
def hideShowMasterViewButtonPressed(sender)
self.hideMasterView = !self.hideMasterView
self.splitViewController.view.setNeedsLayout
end

# Delegate Method
def splitViewController(svc, shouldHideViewController:vc, inOrientation:orientation)
self.hideMasterView
end

This is where I got the idea.

关于ios - 是否可以动态关闭菜单(分屏),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20372788/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com