gpt4 book ai didi

swift - 按菜单按钮时 tvOS 更改目的地

转载 作者:行者123 更新时间:2023-11-30 12:53:06 27 4
gpt4 key购买 nike

假设我有 3 个 ViewController ABC

A 有一个到 B 的跳转,如果我在 B,我只需按菜单按钮即可返回到 B>一个。

B 有一个到 C 的跳转,但是当我在 C 时,我不希望用户返回到 <通过菜单按钮strong>B,但我希望他改为A(也就是说,如果他在C,如果他按菜单按钮,他应该去A)。

我该怎么做?我正在使用 Swift

最佳答案

我找到了答案。

假设这些是 ViewController C 上的函数。

override func viewDidLoad() {
super.viewDidLoad()

let tapRecognizer = UITapGestureRecognizer(target: self, action: Selector("MenuPressed"))
tapRecognizer.allowedPressTypes = [NSNumber(value: UIPressType.menu.rawValue)]
self.view.addGestureRecognizer(tapRecognizer)
// Do any additional setup after loading the view.
}


func MenuPressed(){
performSegue(withIdentifier: "C_to_A", sender: nil)
}

如果存在从 C 到 A 的 Segue,标识符为“C_to_A”,那么如果用户按菜单(从 C),他将被带到 A(而不是 B)。

关于swift - 按菜单按钮时 tvOS 更改目的地,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40727400/

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