gpt4 book ai didi

ios - 我的 segue 退得太远了

转载 作者:行者123 更新时间:2023-11-28 15:29:03 25 4
gpt4 key购买 nike

This is how my story board currently looks

当我点击按钮垂直放置的 View 上的按钮时,我可以打开正确的相应 View ,但是,当我返回时,我最终会一直回到登录页面,而不是页面按钮。我在正确的地方有放松的 segue,只是不知道为什么它会回到那么远。

这是带有按钮的 View Controller 的代码

@IBOutlet weak var menuButton: UIButton!

@IBOutlet weak var clubButton: UIButton!

@IBOutlet weak var announcemnetsButton: UIButton!

@IBOutlet weak var eventButton: UIButton!

var transition = QZCircleSegue()


override func viewDidLoad() {
super.viewDidLoad()

menuButton.layer.cornerRadius = menuButton.frame.size.width / 2
clubButton.layer.cornerRadius = menuButton.frame.size.width / 2
announcemnetsButton.layer.cornerRadius = menuButton.frame.size.width / 2
eventButton.layer.cornerRadius = menuButton.frame.size.width / 2

menuButton.layer.masksToBounds = true
clubButton.layer.masksToBounds = true
announcemnetsButton.layer.masksToBounds = true
eventButton.layer.masksToBounds = true

}
override var prefersStatusBarHidden : Bool {
return true;

}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if (segue.identifier == "NewVC") {
self.transition.animationChild = menuButton
self.transition.animationColor = UIColor(red: 255/255, green: 0/255, blue: 0/255, alpha: 1.0)
} else if (segue.identifier == "ClubVC") {
self.transition.animationChild = clubButton
self.transition.animationColor = UIColor(red: 81/255, green: 172/255, blue: 246/255, alpha: 1.0)
} else if (segue.identifier == "AnnouncementVC") {
self.transition.animationChild = announcemnetsButton
self.transition.animationColor = UIColor(red: 255/255, green: 179/255, blue: 109/255, alpha: 1.0)
} else if segue.identifier == "EventVC" {
self.transition.animationChild = eventButton
self.transition.animationColor = UIColor(red: 63/255, green: 255/255, blue: 176/255, alpha: 1.0)
}
let toViewController = segue.destination as! NewViewController
/* Set both, the origin and destination to your transition manager*/
self.transition.fromViewController = self
self.transition.toViewController = toViewController
/* Add the transition manager to your transitioningDelegate View Controller*/
toViewController.transitioningDelegate = transition
}

/* Specify the destination view controller to enable the unwind segue*/
@IBAction func unwindToMainViewController (sender: UIStoryboardSegue){
self.dismiss(animated: true, completion: nil)

}

最佳答案

iOS 的评论是正确的。仅仅因为您使用了 segue 来访问 View Controller 并不意味着您必须使用一个来离开。假设你想回到刚才显示的 View Controller ,有两种可能性。您要做的是将当前 View Controller 弹出堆栈。如果您正在使用导航 Controller (很可能是),那么这就是如何做到这一点:

 self.navigationController?.dismiss(animated: true, completion: nil)

您可以将其简化为:

 dismiss(animated: true, completion: nil)

因为 View Controller 有一个 self.dismiss() 方法。试一试,让我知道这是否适合您。

关于ios - 我的 segue 退得太远了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44914048/

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