在当前上下文中呈现ViewController会卡住

时间:2016-10-19 15:05:51

标签: ios swift uimodalpresentationstyle uimodaltransitionstyle touch-up-inside

当我按下按钮("触摸向下")并且当我释放该按钮时(" Touch Up Inside"我试图在当前上下文中模态地呈现视图控制器) )我希望视图控制器被解雇。

这是我的代码:( buttonPressed是" Touch Down"事件和buttonReleased是" Touch Up Inside"事件)

@IBAction func buttonPressed(_ sender: AnyObject) {

    let storyboard = UIStoryboard.init(name: "Main", bundle: .main)
    let anotherView = storyboard.instantiateViewController(withIdentifier: "AnotherView")
    anotherView.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
    anotherView.modalTransitionStyle = UIModalTransitionStyle.crossDissolve
    present(anotherView, animated: true, completion: nil)

}


@IBAction func buttonReleased(_ sender: AnyObject) {
    dismiss(animated: true, completion: nil)
}

但是,如果我发送垃圾邮件按钮,则另一个视图会被卡住并留在那里。有谁知道这个问题的解决方案?谢谢。

编辑:另外,如果我将动画更改为false,这仍然会发生,所以它可能不是问题。

编辑2 我解决了这个问题。我只是从按钮听错了事件。如果您按下并快速释放按钮,似乎被触发的事件是"触摸取消"。我也补充说,我的代码现在正在运行。

0 个答案:

没有答案
相关问题