【发布时间】:2015-09-11 08:30:59
【问题描述】:
我的应用有 7 个后续视图控制器:VC1 - VC7
在我的导航栏中,我有一个带有操作的后退按钮:轻按和长按。当在任何 VC 中长按后退按钮时,应用程序应该转到 VC2 并呈现它,就好像用户从 VC1 转到 VC2 一样,特别是:点击右后退按钮的动作。
这是我的 UILongPressGestureRecognizer 代码:
func longPressAction(gestureRecognizer: UIGestureRecognizer) {
if (gestureRecognizer.state == UIGestureRecognizerState.Ended) {
println("Long press ended")
} else if (gestureRecognizer.state == UIGestureRecognizerState.Began) {
println("Long press detected")
let mainStoryboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
let vc: ViewController2 = mainStoryboard.instantiateViewControllerWithIdentifier("vc2") as! ViewController2
navigationController?.pushViewController(vc, animated: true)
}
}
我怎样才能回到导航堆栈中的正确位置?
【问题讨论】:
标签: ios swift uinavigationcontroller push gesture